Class: OFX::Statement::Output::Builder::OFX1

Inherits:
Builder::XmlMarkup
  • Object
show all
Defined in:
lib/ofx/statement/output/builder.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object

Create SGMLish markup based on the name of the method. This method is never invoked directly, but is called for each markup method in the markup block.

NB, it’s not really SGML, it just doesn’t generate empty tags of the form <tag/> Instead it generates <tag> That’s it, it’s a nasty hack.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ofx/statement/output/builder.rb', line 34

def method_missing(sym, *args, &block)
  text = nil
  attrs = nil
  sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol)
  args.each do |arg|
    case arg
    when Hash
      attrs ||= {}
      attrs.merge!(arg)
    else
      text ||= ''
      text << arg.to_s
    end
  end
  if block
    unless text.nil?
      raise ArgumentError, "XmlMarkup cannot mix a text argument with a block"
    end
    _indent
    _start_tag(sym, attrs)
    _newline
    _nested_structures(block)
    _indent
    _end_tag(sym)
    _newline
  elsif text.nil?
    _indent
    _start_tag(sym, attrs)
    _newline
  else
    _indent
    _start_tag(sym, attrs)
    text! text
    _end_tag(sym)
    _newline
  end
  @target
end

Instance Method Details

#ofx_stanza!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ofx/statement/output/builder.rb', line 14

def ofx_stanza!
  self.text! <<-EOH
OFXHEADER:100
DATA:OFXSGML
VERSION:103
SECURITY:NONE
ENCODING:USASCII
CHARSET:NONE
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
EOH
end