Class: Stupidedi::Values::SimpleElementVal Abstract

Inherits:
AbstractElementVal show all
Defined in:
lib/stupidedi/values/simple_element_val.rb

Overview

This class is abstract.

This must be subclassed to add type- and version-specific functionality. For instance, DateVal adds #day, #month, etc.

See Also:

  • B.1.1.3.1 Data Element

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractElementVal

#element?, #size

Methods inherited from AbstractVal

#blank?, #characters, #composite?, #definition, #descriptor, #element?, #empty?, #functional_group?, #interchange?, #invalid?, #loop?, #present?, #repeated?, #segment?, #separator?, #size, #table?, #transaction_set?, #transmission?

Methods included from Color

ansi, #ansi

Methods included from Inspect

#inspect

Constructor Details

#initialize(usage, position) ⇒ SimpleElementVal

Returns a new instance of SimpleElementVal.



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

def initialize(usage, position)
  @usage, @position =
    usage, position
end

Instance Attribute Details

#positionReader::Position (readonly)

Returns:



31
32
33
# File 'lib/stupidedi/values/simple_element_val.rb', line 31

def position
  @position
end

#usageSimpleElementUse, ComponentElementUse (readonly)

Returns:

  • (SimpleElementUse, ComponentElementUse)


14
# File 'lib/stupidedi/values/simple_element_val.rb', line 14

def_delegators :usage, :definition, :descriptor

Instance Method Details

#allowed?Boolean

True unless this value isn't included in Schema::SimpleElementUse#allowed_values

Returns:

  • (Boolean)


42
43
44
# File 'lib/stupidedi/values/simple_element_val.rb', line 42

def allowed?
  empty? or invalid? or usage.allowed_values.include?(to_s)
end

#component?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/stupidedi/values/simple_element_val.rb', line 71

def component?
  @usage.component?
end

#copySimpleElementVal

Returns:



39
# File 'lib/stupidedi/values/simple_element_val.rb', line 39

abstract :copy, "changes={}"

#date?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/stupidedi/values/simple_element_val.rb', line 50

def date?
  false
end

#id?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/stupidedi/values/simple_element_val.rb', line 46

def id?
  false
end

#leaf?Boolean

Returns true.

Returns:

  • (Boolean)

    true



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

def leaf?
  true
end

#numeric?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/stupidedi/values/simple_element_val.rb', line 62

def numeric?
  false
end

#simple?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/stupidedi/values/simple_element_val.rb', line 75

def simple?
  not @usage.component?
end

#string?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/stupidedi/values/simple_element_val.rb', line 58

def string?
  false
end

#time?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/stupidedi/values/simple_element_val.rb', line 54

def time?
  false
end

#to_s

This method is abstract.


25
# File 'lib/stupidedi/values/simple_element_val.rb', line 25

abstract :to_s

#to_x12String

Returns:

  • (String)


19
# File 'lib/stupidedi/values/simple_element_val.rb', line 19

abstract :to_x12

#too_long?Boolean

This method is abstract.

Returns:

  • (Boolean)


21
# File 'lib/stupidedi/values/simple_element_val.rb', line 21

abstract :too_long?

#too_short?Boolean

This method is abstract.

Returns:

  • (Boolean)


23
# File 'lib/stupidedi/values/simple_element_val.rb', line 23

abstract :too_short?

#valid?Boolean

This method is abstract.

Returns:

  • (Boolean)


16
# File 'lib/stupidedi/values/simple_element_val.rb', line 16

abstract :valid?