Class: Ppp::Card::Xml
Instance Attribute Summary
Attributes inherited from Base
#card_number, #row_count, #title
Instance Method Summary collapse
-
#initialize(generator, opts = {}) ⇒ Xml
constructor
A new instance of Xml.
- #to_s ⇒ Object
Methods inherited from Base
#code_length, #codes, #passcode, #passcodes_per_card, #passcodes_per_line, #verify
Constructor Details
#initialize(generator, opts = {}) ⇒ Xml
Returns a new instance of Xml.
5 6 7 |
# File 'lib/ppp/card/xml.rb', line 5 def initialize generator, opts={} super end |
Instance Method Details
#to_s ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ppp/card/xml.rb', line 9 def to_s rows = codes.each_with_index.collect do |row, i| cols = row.each_with_index.collect { |code, j| " <column label=\"#{column_label(j+1)}\">#{code}</column>" }.join(?\n) " <row number=\"#{i+1}\">\n#{cols}\n </row>\n" end.join(?\n) %[<?xml version="1.0" encoding="UTF-8" ?>\n] + %[<card title="#{@title}" number="#{card_number}">\n] + rows + %[</card>\n] end |