Class: InstaReadability::Bookmark

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

Constant Summary collapse

ATTRIBUTES =
[:url, :favorite, :archive, :allow_duplicates]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Bookmark

Returns a new instance of Bookmark.



6
7
8
9
# File 'lib/insta_readability/bookmark.rb', line 6

def initialize(options={})
  @archive, @favorite, @allow_duplicates = 0, 0, 0
  options.each_pair { |attr, value| instance_variable_set("@#{attr}", value) }
end

Instance Method Details

#==(o) ⇒ Object Also known as: eql?



11
12
13
# File 'lib/insta_readability/bookmark.rb', line 11

def ==(o)
  o.class == self.class && o.to_hash == to_hash
end

#to_hashObject



16
17
18
19
20
21
# File 'lib/insta_readability/bookmark.rb', line 16

def to_hash
  ATTRIBUTES.inject({}) do |hash, attribute|
    hash[attribute] = self.send attribute.to_s
    hash
  end
end