Class: Stupidedi::Values::FunctionalGroupVal

Inherits:
AbstractVal
  • Object
show all
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?, #descriptor, #element?, #empty?, #interchange?, #invalid?, #leaf?, #loop?, #present?, #repeated?, #segment?, #separator?, #simple?, #size, #table?, #transaction_set?, #transmission?, #valid?

Methods included from Color

ansi, #ansi

Constructor Details

#initialize(definition, children) ⇒ FunctionalGroupVal

Returns a new instance of FunctionalGroupVal.



23
24
25
26
# File 'lib/stupidedi/values/functional_group_val.rb', line 23

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

Instance Attribute Details

#childrenArray<SegmentVal, TransactionSetVal> (readonly)

Returns:



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

def children
  @children
end

#definitionFunctionalGroupDef (readonly)

Returns:

  • (FunctionalGroupDef)


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

def definition
  @definition
end

Instance Method Details

#==(other)



98
99
100
101
102
# File 'lib/stupidedi/values/functional_group_val.rb', line 98

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

#copy(changes = {}) ⇒ FunctionalGroupVal

Returns:



29
30
31
32
33
# File 'lib/stupidedi/values/functional_group_val.rb', line 29

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

#functional_group?Boolean

Returns:

  • (Boolean)

    true



37
38
39
# File 'lib/stupidedi/values/functional_group_val.rb', line 37

def functional_group?
  true
end

#implementationString?

Returns:

  • (String, nil)


63
64
65
66
67
# File 'lib/stupidedi/values/functional_group_val.rb', line 63

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

#inspectString

Returns:

  • (String)


94
95
96
# File 'lib/stupidedi/values/functional_group_val.rb', line 94

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

#pretty_print(q)

This method returns an undefined value.



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

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

#releaseString?

Returns:

  • (String, nil)


49
50
51
52
53
# File 'lib/stupidedi/values/functional_group_val.rb', line 49

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

#segment_dictModule

Returns:

  • (Module)


70
71
72
# File 'lib/stupidedi/values/functional_group_val.rb', line 70

def segment_dict
  @definition.segment_dict
end

#subreleaseString?

Returns:

  • (String, nil)


56
57
58
59
60
# File 'lib/stupidedi/values/functional_group_val.rb', line 56

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

#versionString?

Returns:

  • (String, nil)


42
43
44
45
46
# File 'lib/stupidedi/values/functional_group_val.rb', line 42

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