Class: Riif::DSL::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/riif/dsl/base.rb
Direct Known Subclasses
Accnt, Bud, Ctype, Cust, Emp, Invitem, Invmemo, Klass, Othername, Paymeth, Shipmeth, Spl, Terms, Timeact, Timerhdr, Trns, Vend, Vtype
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
4
5
6
7
|
# File 'lib/riif/dsl/base.rb', line 4
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
43
44
45
46
47
48
49
|
# File 'lib/riif/dsl/base.rb', line 43
def method_missing(method_name, *args, &block)
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
9
10
11
12
13
14
|
# File 'lib/riif/dsl/base.rb', line 9
def build(&block)
instance_eval(&block)
output
end
|
31
32
33
34
35
36
37
|
# File 'lib/riif/dsl/base.rb', line 31
def
[
["!#{self.class::START_COLUMN}"].concat(
self.class::HEADER_COLUMNS.map(&:upcase)
)
]
end
|
#output ⇒ Object
24
25
26
27
28
29
|
# File 'lib/riif/dsl/base.rb', line 24
def output
{
headers: ,
rows: rows
}
end
|
#row(&block) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/riif/dsl/base.rb', line 16
def row(&block)
@current_row = [self.class::START_COLUMN]
instance_eval(&block)
@rows << @current_row
end
|
#rows ⇒ Object
39
40
41
|
# File 'lib/riif/dsl/base.rb', line 39
def rows
@rows
end
|