Class: Keepasser::Parser
- Inherits:
-
Hash
- Object
- Hash
- Keepasser::Parser
- Defined in:
- lib/keepasser/parser.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(path) ⇒ Parser
Returns a new instance of Parser.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/keepasser/parser.rb', line 5 def initialize path @path = path lines = File.readlines @path bucket= [] lines.each do |line| if line[0..8] == '*** Group' @group = line[11..-6] self[@group] = {} else unless line == "\n" bucket.push line else if bucket.any? e = Entry.new bucket e.group = @group self[@group][e.title] = e.clone bucket = [] end end end end e = Entry.new bucket e.group = @group self[@group][e.title] = e.clone end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/keepasser/parser.rb', line 3 def path @path end |