Class: Stupidedi::Values::TableVal

Inherits:
AbstractVal show all
Includes:
SegmentValGroup
Defined in:
lib/stupidedi/values/table_val.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SegmentValGroup

#leaf?

Methods inherited from AbstractVal

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

Methods included from Color

ansi, #ansi

Constructor Details

#initialize(definition, children) ⇒ TableVal

Returns a new instance of TableVal.



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

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

Instance Attribute Details

#childrenArray<SegmentVal, LoopVal> (readonly)

Returns:



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

def children
  @children
end

#definitionTableDef (readonly)

Returns:

  • (TableDef)


10
11
12
# File 'lib/stupidedi/values/table_val.rb', line 10

def definition
  @definition
end

Instance Method Details

#==(other) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
65
66
# File 'lib/stupidedi/values/table_val.rb', line 62

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

#copy(changes = {}) ⇒ TableVal

Returns:



25
26
27
28
29
# File 'lib/stupidedi/values/table_val.rb', line 25

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

#inspectString

Returns:

  • (String)


57
58
59
# File 'lib/stupidedi/values/table_val.rb', line 57

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

#pretty_print(q)

This method returns an undefined value.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/stupidedi/values/table_val.rb', line 38

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

  q.text(ansi.table("TableVal#{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

#table?

Returns:

  • true



33
34
35
# File 'lib/stupidedi/values/table_val.rb', line 33

def table?
  true
end