rwrk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rwrk.rb +49 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '099ceaa0b400a7495564eaae94c6e56b2103b581ee77c26058cf1a37daa76a7d'
|
4
|
+
data.tar.gz: dc471a7d402a0853a956fb31e67ffa7fa85847622579510888272b4ae074416e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51c0d0fa804a2923141ab391844072e7a7d3133ce62e24a3359530f2e47d36c72b413939d9ea313e34eb32df62adff77b2cbe0107e80ce249cf3de01a6dec562
|
7
|
+
data.tar.gz: c4daba537665aa0807ced9b8d790f0e5c99237654c6b2b970f259fbb8eb5738818d8a9bfa652798229cb2e01d725eb012ac7571b18c8562e4ed791158bb38402
|
data/lib/rwrk.rb
CHANGED
@@ -1,5 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'HTTP'
|
2
|
+
|
3
|
+
class Building
|
4
|
+
attr_reader :id, :name, :address, :height, :construction_date, :architect
|
5
|
+
|
6
|
+
def initialize(input_options)
|
7
|
+
@id = input_options["id"]
|
8
|
+
@name = input_options["name"]
|
9
|
+
@address = input_options["address"]
|
10
|
+
@height = input_options["height"]
|
11
|
+
@construction_date = input_options["construction_date"]
|
12
|
+
@architect = input_options["architect"]
|
4
13
|
end
|
5
|
-
|
14
|
+
|
15
|
+
def self.all
|
16
|
+
response = HTTP.get("http://localhost:3000/api/buildings")
|
17
|
+
response.parse.map do |data|
|
18
|
+
Building.new(data)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.create(input_options)
|
23
|
+
response = HTTP.post(
|
24
|
+
"http://localhost:3000/api/buildings",
|
25
|
+
form: input_options
|
26
|
+
)
|
27
|
+
Building.new(response.parse)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.find(input_id)d
|
31
|
+
response = HTTP.get("http://localhost:3000/api/buildings/#{input_id}")
|
32
|
+
Building.new(response.parse)
|
33
|
+
end
|
34
|
+
|
35
|
+
def update(input_options)
|
36
|
+
response = HTTP.patch(
|
37
|
+
"http://localhost:3000/api/buildings/#{self.id}",
|
38
|
+
form: input_options
|
39
|
+
)
|
40
|
+
Building.new(response.parse)
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
response = HTTP.delete("http://localhost:3000/api/buildings/#{self.id}")
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.test
|
48
|
+
p "YEAH BUDDY"
|
49
|
+
end
|
50
|
+
end
|