Class: Ticard::Card
- Inherits:
-
Object
- Object
- Ticard::Card
- Defined in:
- lib/ticard/card.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#stored_md5 ⇒ Object
readonly
Returns the value of attribute stored_md5.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #as_stored ⇒ Object
- #current_md5 ⇒ Object
- #from_same_content_as?(other_card) ⇒ Boolean
-
#initialize(content, opts = {}) ⇒ Card
constructor
A new instance of Card.
Constructor Details
#initialize(content, opts = {}) ⇒ Card
Returns a new instance of Card.
8 9 10 11 12 |
# File 'lib/ticard/card.rb', line 8 def initialize(content, opts={}) @content = content @stored_md5 = opts[:stored_md5] @url = opts[:url] end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/ticard/card.rb', line 6 def content @content end |
#stored_md5 ⇒ Object (readonly)
Returns the value of attribute stored_md5.
6 7 8 |
# File 'lib/ticard/card.rb', line 6 def stored_md5 @stored_md5 end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/ticard/card.rb', line 6 def url @url end |
Instance Method Details
#as_stored ⇒ Object
22 23 24 |
# File 'lib/ticard/card.rb', line 22 def as_stored Card.new(@content, :url => @url, :stored_md5 => current_md5) end |
#current_md5 ⇒ Object
14 15 16 |
# File 'lib/ticard/card.rb', line 14 def current_md5 Digest::MD5.hexdigest(@content.strip) end |
#from_same_content_as?(other_card) ⇒ Boolean
18 19 20 |
# File 'lib/ticard/card.rb', line 18 def from_same_content_as?(other_card) @stored_md5 == other_card.stored_md5 end |