b_rabbit 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/b_rabbit.rb +44 -0
  3. metadata +43 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6983428cf014726f36a091c1fcf320e6b13314e4f7071d43dc721cc1d4edc078
4
+ data.tar.gz: ca93ef322c278861531bc023ea7bf40224ab68b53eaee2c836229713156fb267
5
+ SHA512:
6
+ metadata.gz: a62e87d02c966f1bcbf5752b61b0e0d1ed4e1566510f7f37c26b28e0be3657cefddba6647b21e123e320330901e732551c21132baf55144e01cc8d9944a4e128
7
+ data.tar.gz: 327bd618430b59a092ca8b3a2c411dfd41f9fc3c84e28ba76cdddd3d5f17ce25dccf59ade96152fafa7c56ca607a831806d21ba370ab3bae4ec18e0610dccf0b
@@ -0,0 +1,44 @@
1
+ require 'HTTP'
2
+ class Building
3
+ attr_reader :id, :name, :address, :height, :construction_date, :architect
4
+
5
+ def initialize(input_options)
6
+ @id = input_options["id"]
7
+ @name = input_options["name"]
8
+ @address = input_options["address"]
9
+ @height = input_options["height"]
10
+ @construction_date = input_options["construction_date"]
11
+ @architect = input_options["architect"]
12
+ end
13
+
14
+
15
+ def self.find(input_id)
16
+ response = HTTP.get("http://localhost:3000/api/buildings/#{input_id}")
17
+ Building.new(response.parse)
18
+ end
19
+
20
+ def self.all
21
+ response = HTTP.get("http://localhost:3000/api/buildings")
22
+ response.parse.map {|element| Building.new(element)}
23
+ end
24
+
25
+ def self.create(input_options)
26
+ response = HTTP.post("http://localhost:3000/api/buildings",
27
+ form: input_options
28
+ )
29
+ Building.new(response.parse)
30
+ end
31
+
32
+ def update(input_options)
33
+ response = HTTP.patch("http://localhost:3000/api/buildings/#{self.id}",
34
+ form: input_options
35
+ )
36
+ Building.new(response.parse)
37
+ end
38
+
39
+ def destroy
40
+ response = HTTP.delete("http://localhost:3000/api/buildings/#{self.id}")
41
+ end
42
+
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: b_rabbit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jamal Numan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple hello world gem
14
+ email: jnuman82@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/b_rabbit.rb
20
+ homepage: https://rubygems.org/gems/brabbit
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.0.3
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: For class!
43
+ test_files: []