Class: Leaflyapi::Strains
- Inherits:
-
Object
- Object
- Leaflyapi::Strains
- Defined in:
- lib/leaflyapi.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#effects ⇒ Object
readonly
Returns the value of attribute effects.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#medical_uses ⇒ Object
readonly
Returns the value of attribute medical_uses.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#overview ⇒ Object
readonly
Returns the value of attribute overview.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#reviews ⇒ Object
readonly
Returns the value of attribute reviews.
-
#side_effects ⇒ Object
readonly
Returns the value of attribute side_effects.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Strains
constructor
A new instance of Strains.
Constructor Details
#initialize(data) ⇒ Strains
Returns a new instance of Strains.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/leaflyapi.rb', line 39 def initialize(data) @id = data["Id"] @key = data["Key"] @name = data["Name"] @category = data["Category"] @symbol = data["Symmbol"] @description = data["Abstract"] @url = data["Url"] @rating = data["Rating"] @effects = data["Effects"] @medical_uses = data["Medical"] @side_effects = data["Negative"] @reviews = data["Reviews"] end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def category @category end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def description @description end |
#effects ⇒ Object (readonly)
Returns the value of attribute effects.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def effects @effects end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def key @key end |
#medical_uses ⇒ Object (readonly)
Returns the value of attribute medical_uses.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def medical_uses @medical_uses end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def name @name end |
#overview ⇒ Object (readonly)
Returns the value of attribute overview.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def overview @overview end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def @rating end |
#reviews ⇒ Object (readonly)
Returns the value of attribute reviews.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def reviews @reviews end |
#side_effects ⇒ Object (readonly)
Returns the value of attribute side_effects.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def side_effects @side_effects end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def symbol @symbol end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
35 36 37 |
# File 'lib/leaflyapi.rb', line 35 def url @url end |
Class Method Details
.all ⇒ Object
7 8 9 10 11 |
# File 'lib/leaflyapi.rb', line 7 def self.all response = ::HTTParty.get("http://www.leafly.com/api/strains") strains_json = ::JSON.parse(response.body) strains_json.collect {|strain| new (strain)} end |
.find_by_category(category) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/leaflyapi.rb', line 27 def self.find_by_category(category) response = ::HTTParty.get("http://www.leafly.com/api/strains?category=#{category}") strains_json = ::JSON.parse(response.body) strains_json.map do |strain| strain["Key"] end end |
.find_by_key(key) ⇒ Object
21 22 23 24 25 |
# File 'lib/leaflyapi.rb', line 21 def self.find_by_key(key) response = ::HTTParty.get("http://www.leafly.com/api/details/#{key}") strain_json = ::JSON.parse(response.body) new (strain_json) end |
.keys ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/leaflyapi.rb', line 13 def self.keys response = ::HTTParty.get("http://www.leafly.com/api/strains") strains_json = ::JSON.parse(response.body) strains_json.map do |strain| strain["Key"] end end |