Class: Trendious::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/trendious/entry.rb

Direct Known Subclasses

Post, Tag

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#entryObject (readonly)

Returns the value of attribute entry.



5
6
7
# File 'lib/trendious/entry.rb', line 5

def entry
  @entry
end

Instance Method Details



19
20
21
# File 'lib/trendious/entry.rb', line 19

def link
  URI.join "http://moviepilot.com", type_path, id.to_s
end

#readObject



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_pathObject



23
24
25
# File 'lib/trendious/entry.rb', line 23

def type_path
  "#{type.pluralize}/"
end