Class: SimpleTumblr::Post

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

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Post

Returns a new instance of Post.



61
62
63
# File 'lib/simple_tumblr.rb', line 61

def initialize(data)
  self.data = data.with_indifferent_access
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



71
72
73
74
# File 'lib/simple_tumblr.rb', line 71

def method_missing(*args)
  method = args.first.to_sym
  data.has_key?(method) ? data[method] : super
end

Instance Method Details

#<=>(other) ⇒ Object



67
68
69
# File 'lib/simple_tumblr.rb', line 67

def <=>(other)
  self[:timestamp] <=> other[:timestamp]
end

#bodyObject



81
82
83
# File 'lib/simple_tumblr.rb', line 81

def body
  attribute_presence(:body)
end

#titleObject Also known as: to_s



76
77
78
# File 'lib/simple_tumblr.rb', line 76

def title
  attribute_presence(:title, :caption, :text)
end

#urlObject



85
86
87
# File 'lib/simple_tumblr.rb', line 85

def url
  attribute_presence(:url, :link_url, :post_url)
end