Class: Pine2CSV
- Inherits:
-
Object
- Object
- Pine2CSV
- Defined in:
- lib/pine2csv.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#abook ⇒ Object
Returns the value of attribute abook.
Instance Method Summary collapse
-
#initialize(abook = nil) ⇒ Pine2CSV
constructor
A new instance of Pine2CSV.
- #to_csv ⇒ Object
Constructor Details
#initialize(abook = nil) ⇒ Pine2CSV
16 17 18 19 |
# File 'lib/pine2csv.rb', line 16 def initialize(abook = nil) @abook = abook @parser = PineAddressbookParser.new end |
Instance Attribute Details
#abook ⇒ Object
Returns the value of attribute abook.
14 15 16 |
# File 'lib/pine2csv.rb', line 14 def abook @abook end |
Instance Method Details
#to_csv ⇒ Object
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 |