Class: Ticard::Card

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



6
7
8
# File 'lib/ticard/card.rb', line 6

def content
  @content
end

#stored_md5Object (readonly)

Returns the value of attribute stored_md5.



6
7
8
# File 'lib/ticard/card.rb', line 6

def stored_md5
  @stored_md5
end

#urlObject (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_storedObject



22
23
24
# File 'lib/ticard/card.rb', line 22

def as_stored
  Card.new(@content, :url => @url, :stored_md5 => current_md5)
end

#current_md5Object



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

Returns:

  • (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