Class: Tweethook::Post

Inherits:
Array
  • Object
show all
Defined in:
lib/tweethook/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Post

Returns a new instance of Post.



5
6
7
8
9
10
# File 'lib/tweethook/post.rb', line 5

def initialize(json)
  hash = json.is_a?(Hash) ? json : JSON.parse(json)
  @signature = hash['signature']
  @time = Time.at(hash['time'])
  super(hash['results'].map { |result| Tweethook::Result.new(result) })
end

Instance Attribute Details

#signatureObject

Returns the value of attribute signature.



3
4
5
# File 'lib/tweethook/post.rb', line 3

def signature
  @signature
end

#timeObject

Returns the value of attribute time.



3
4
5
# File 'lib/tweethook/post.rb', line 3

def time
  @time
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/tweethook/post.rb', line 12

def valid?
  @signature.eql?(Tweethook.signature)
end