class Strain

Attributes

category[R]
description[R]
effects[R]
id[R]
key[R]
medical_uses[R]
name[R]
overview[R]
rating[R]
reviews[R]
side_effects[R]
symbol[R]
url[R]

Public Class Methods

all_key_names() click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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
new(data) click to toggle source
# 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"]
  @rating = 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