Class: Ticard::Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Parser

Returns a new instance of Parser.



4
5
6
# File 'lib/ticard/parser.rb', line 4

def initialize(text)
  @text = text
end

Instance Method Details

#contentObject



12
13
14
15
# File 'lib/ticard/parser.rb', line 12

def content
  regex = /.*<!---.*?-->[\b\n]*(.*)/m
  regex.match(@text)[1]
end

#metadata(field) ⇒ Object



17
18
19
20
# File 'lib/ticard/parser.rb', line 17

def (field)
  regex = /.*<!---.*?^\b*#{field} (.+?)$.*-->.+/m
  regex.match(@text)[1]
end

#parseObject



8
9
10
# File 'lib/ticard/parser.rb', line 8

def parse
  Card.new(content, :url => ("url"), :stored_md5 => ("md5"))
end