Class: Strain
- Inherits:
-
Object
- Object
- Strain
- Defined in:
- lib/rolling_paper/strain.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
- .all_key_names ⇒ Object
- .all_strains ⇒ Object
- .find_by_category(category) ⇒ Object
- .find_by_key(key) ⇒ Object
Instance Method Summary collapse
-
#initialize(data) ⇒ Strain
constructor
A new instance of Strain.
Constructor Details
#initialize(data) ⇒ Strain
Returns a new instance of Strain.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rolling_paper/strain.rb', line 36 def initialize(data) @key = data["Key"] @id = data["Id"] @name = data["Name"] @category = data["Category"] @description = data["Abstract"] @symbol = data["Symbol"] @overview = data["Overview"] @url = data["Url"] = data["Rating"] @effects = data["Effects"] #returns an array of hashes for each effect @medical_uses = data["Medical"] @side_effects = data["Negative"] @reviews = data["Reviews"] end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def category @category end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def description @description end |
#effects ⇒ Object (readonly)
Returns the value of attribute effects.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def effects @effects end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def key @key end |
#medical_uses ⇒ Object (readonly)
Returns the value of attribute medical_uses.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def medical_uses @medical_uses end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def name @name end |
#overview ⇒ Object (readonly)
Returns the value of attribute overview.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def overview @overview end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def end |
#reviews ⇒ Object (readonly)
Returns the value of attribute reviews.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def reviews @reviews end |
#side_effects ⇒ Object (readonly)
Returns the value of attribute side_effects.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def side_effects @side_effects end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def symbol @symbol end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
32 33 34 |
# File 'lib/rolling_paper/strain.rb', line 32 def url @url end |
Class Method Details
.all_key_names ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/rolling_paper/strain.rb', line 12 def self.all_key_names response = Faraday.get("http://www.leafly.com/api/strains") strains_json = JSON.parse(response.body) strains_json.collect do |strain| strain["Key"] end end |
.all_strains ⇒ Object
6 7 8 9 10 |
# File 'lib/rolling_paper/strain.rb', line 6 def self.all_strains response = Faraday.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
26 27 28 29 30 |
# File 'lib/rolling_paper/strain.rb', line 26 def self.find_by_category(category) response = Faraday.get("http://www.leafly.com/api/strains?category=#{category}") strains_json = JSON.parse(response.body) strains_json.collect {|strain| new (strain)} end |
.find_by_key(key) ⇒ Object
20 21 22 23 24 |
# File 'lib/rolling_paper/strain.rb', line 20 def self.find_by_key(key) response = Faraday.get("http://www.leafly.com/api/details/#{key}") strain_json = JSON.parse(response.body) new (strain_json) end |