Class: QbIif::DSL::Base
Direct Known Subclasses
Accnt, Bud, Class, Ctype, Cust, Emp, Invitem, Invmemo, Othername, Paymeth, Shipmeth, Spl, Terms, Timeact, Timerhdr, Todo, Trns, Vend, Vtype
Constant Summary
Constants included
from Keywords
Keywords::ESCAPED_KEYWORDS
Instance Method Summary
collapse
Methods included from Keywords
#escaped
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
6
7
8
9
|
# File 'lib/qb_iif/dsl/base.rb', line 6
def initialize
@rows = []
@current_row = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/qb_iif/dsl/base.rb', line 45
def method_missing(method_name, *args, &block)
method_name = escaped(method_name)
if self.class::HEADER_COLUMNS.include?(method_name)
@current_row[self.class::HEADER_COLUMNS.index(method_name) + 1] = args[0]
else
super
end
end
|
Instance Method Details
#build(&block) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/qb_iif/dsl/base.rb', line 11
def build(&block)
instance_eval(&block)
output
end
|
33
34
35
36
37
38
39
|
# File 'lib/qb_iif/dsl/base.rb', line 33
def
[
["!#{self.class::START_COLUMN}"].concat(
self.class::HEADER_COLUMNS.map(&:upcase)
)
]
end
|
#output ⇒ Object
26
27
28
29
30
31
|
# File 'lib/qb_iif/dsl/base.rb', line 26
def output
{
headers: ,
rows: rows
}
end
|
#row(&block) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/qb_iif/dsl/base.rb', line 18
def row(&block)
@current_row = [self.class::START_COLUMN]
instance_eval(&block)
@rows << @current_row
end
|
#rows ⇒ Object
41
42
43
|
# File 'lib/qb_iif/dsl/base.rb', line 41
def rows
@rows
end
|