Class: Trendious::Entry
- Inherits:
-
Object
- Object
- Trendious::Entry
- Defined in:
- lib/trendious/entry.rb
Instance Attribute Summary collapse
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Entry
constructor
A new instance of Entry.
- #link ⇒ Object
- #read ⇒ Object
- #type_path ⇒ Object
Constructor Details
#initialize(hash) ⇒ Entry
Returns a new instance of Entry.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/trendious/entry.rb', line 7 def initialize hash @entry = hash @entry.keys.each do |k| self.class.instance_eval do define_method(k) do @entry[k] end end end end |
Instance Attribute Details
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
5 6 7 |
# File 'lib/trendious/entry.rb', line 5 def entry @entry end |
Instance Method Details
#link ⇒ Object
19 20 21 |
# File 'lib/trendious/entry.rb', line 19 def link URI.join "http://moviepilot.com", type_path, id.to_s end |
#read ⇒ Object
27 28 29 30 31 |
# File 'lib/trendious/entry.rb', line 27 def read uri = URI.join "http://api.moviepilot.com", "/v4/", type_path, id.to_s JSON.parse(Net::HTTP.get(uri)) end |
#type_path ⇒ Object
23 24 25 |
# File 'lib/trendious/entry.rb', line 23 def type_path "#{type.pluralize}/" end |