Class: Stupidedi::Values::FunctionalGroupVal

Inherits:
AbstractVal show all
Extended by:
Forwardable
Includes:
SegmentValGroup
Defined in:
lib/stupidedi/values/functional_group_val.rb

Overview

See Also:

  • B.1.1.3.13 Functional Group
  • B.1.1.4.2 Functional Groups

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from SegmentValGroup

#leaf?

Methods inherited from AbstractVal

#blank?, #characters, #component?, #composite?, #element?, #empty?, #interchange?, #invalid?, #loop?, #present?, #repeated?, #segment?, #separator?, #simple?, #size, #table?, #transaction_set?, #transmission?, #valid?

Methods included from Color

ansi, #ansi

Constructor Details

- (FunctionalGroupVal) initialize(definition, children)



20
21
22
23
# File 'lib/stupidedi/values/functional_group_val.rb', line 20

def initialize(definition, children)
  @definition, @children =
    definition, children
end

Instance Attribute Details

- (Array<SegmentVal, TransactionSetVal>) children (readonly)



15
16
17
# File 'lib/stupidedi/values/functional_group_val.rb', line 15

def children
  @children
end

- (FunctionalGroupDef) definition (readonly)



12
13
14
# File 'lib/stupidedi/values/functional_group_val.rb', line 12

def definition
  @definition
end

Instance Method Details

- ==(other)



95
96
97
98
99
# File 'lib/stupidedi/values/functional_group_val.rb', line 95

def ==(other)
  eql?(other) or
    (other.definition == @definition or
     other.children   == @children)
end

- (FunctionalGroupVal) copy(changes = {})



26
27
28
29
30
# File 'lib/stupidedi/values/functional_group_val.rb', line 26

def copy(changes = {})
  FunctionalGroupVal.new \
    changes.fetch(:definition, @definition),
    changes.fetch(:children, @children)
end

- (Boolean) functional_group?



34
35
36
# File 'lib/stupidedi/values/functional_group_val.rb', line 34

def functional_group?
  true
end

- (String?) implementation



60
61
62
63
64
# File 'lib/stupidedi/values/functional_group_val.rb', line 60

def implementation
  if at(6) == "X"
    at(7).to_s.slice(6, 4)
  end
end

- (String) inspect



91
92
93
# File 'lib/stupidedi/values/functional_group_val.rb', line 91

def inspect
  ansi.envelope("Group") << "(#{@children.map(&:inspect).join(', ')})"
end

- pretty_print(q)



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/stupidedi/values/functional_group_val.rb', line 72

def pretty_print(q)
  id = @definition.try do |d|
    ansi.bold("[#{d.id.to_s}]")
  end

  q.text(ansi.envelope("FunctionalGroupVal#{id}"))
  q.group(2, "(", ")") do
    q.breakable ""
    @children.each do |e|
      unless q.current_group.first?
        q.text ", "
        q.breakable
      end
      q.pp e
    end
  end
end

- (String?) release



46
47
48
49
50
# File 'lib/stupidedi/values/functional_group_val.rb', line 46

def release
  if at(6) == "X"
    at(7).to_s.slice(0, 4)
  end
end

- (Module) segment_dict



67
68
69
# File 'lib/stupidedi/values/functional_group_val.rb', line 67

def segment_dict
  @definition.segment_dict
end

- (String?) subrelease



53
54
55
56
57
# File 'lib/stupidedi/values/functional_group_val.rb', line 53

def subrelease
  if at(6) == "X"
    at(7).to_s.slice(0, 5)
  end
end

- (String?) version



39
40
41
42
43
# File 'lib/stupidedi/values/functional_group_val.rb', line 39

def version
  if at(6) == "X"
    at(7).to_s.slice(0, 3)
  end
end