Class: Pine2CSV

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

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(abook = nil) ⇒ Pine2CSV

Returns a new instance of Pine2CSV.



16
17
18
19
# File 'lib/pine2csv.rb', line 16

def initialize(abook = nil)
  @abook = abook
  @parser = PineAddressbookParser.new
end

Instance Attribute Details

#abookObject

Returns the value of attribute abook.



14
15
16
# File 'lib/pine2csv.rb', line 14

def abook
  @abook
end

Instance Method Details

#to_csvObject

Raises:



29
30
31
32
33
34
35
36
# File 'lib/pine2csv.rb', line 29

def to_csv
  raise Pine2CSV::Error.new("No address book data supplied.") unless abook
  tree = @parser.parse(@abook)

  raise Pine2CSV::Error.new("Parse failure:\n#{@parser.failure_reason}") unless tree

  tree.to_csv
end