Class: Stupidedi::Values::SimpleElementVal Abstract

Inherits:
AbstractElementVal show all
Extended by:
Forwardable
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

Direct Known Subclasses

Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::DateVal, Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::FixnumVal, Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::FloatVal, Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::IdentifierVal, Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::StringVal, Stupidedi::Versions::FunctionalGroups::FiftyTen::ElementTypes::TimeVal, Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::DateVal, Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::FixnumVal, Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::FloatVal, Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::IdentifierVal, Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::StringVal, Stupidedi::Versions::FunctionalGroups::FortyTen::ElementTypes::TimeVal, Stupidedi::Versions::FunctionalGroups::ThirtyFifty::ElementTypes::DateVal, Stupidedi::Versions::FunctionalGroups::ThirtyFifty::ElementTypes::FixnumVal, Stupidedi::Versions::FunctionalGroups::ThirtyFifty::ElementTypes::FloatVal, Stupidedi::Versions::FunctionalGroups::ThirtyFifty::ElementTypes::IdentifierVal, Stupidedi::Versions::FunctionalGroups::ThirtyFifty::ElementTypes::StringVal, Stupidedi::Versions::FunctionalGroups::ThirtyFifty::ElementTypes::TimeVal, Stupidedi::Versions::FunctionalGroups::ThirtyForty::ElementTypes::DateVal, Stupidedi::Versions::FunctionalGroups::ThirtyForty::ElementTypes::FixnumVal, Stupidedi::Versions::FunctionalGroups::ThirtyForty::ElementTypes::FloatVal, Stupidedi::Versions::FunctionalGroups::ThirtyForty::ElementTypes::IdentifierVal, Stupidedi::Versions::FunctionalGroups::ThirtyForty::ElementTypes::StringVal, Stupidedi::Versions::FunctionalGroups::ThirtyForty::ElementTypes::TimeVal, Stupidedi::Versions::FunctionalGroups::ThirtyTen::ElementTypes::DateVal, Stupidedi::Versions::FunctionalGroups::ThirtyTen::ElementTypes::FixnumVal, Stupidedi::Versions::FunctionalGroups::ThirtyTen::ElementTypes::FloatVal, Stupidedi::Versions::FunctionalGroups::ThirtyTen::ElementTypes::IdentifierVal, Stupidedi::Versions::FunctionalGroups::ThirtyTen::ElementTypes::StringVal, Stupidedi::Versions::FunctionalGroups::ThirtyTen::ElementTypes::TimeVal, Stupidedi::Versions::FunctionalGroups::TwoThousandOne::ElementTypes::DateVal, Stupidedi::Versions::FunctionalGroups::TwoThousandOne::ElementTypes::FixnumVal, Stupidedi::Versions::FunctionalGroups::TwoThousandOne::ElementTypes::FloatVal, Stupidedi::Versions::FunctionalGroups::TwoThousandOne::ElementTypes::IdentifierVal, Stupidedi::Versions::FunctionalGroups::TwoThousandOne::ElementTypes::StringVal, Stupidedi::Versions::FunctionalGroups::TwoThousandOne::ElementTypes::TimeVal, Stupidedi::Versions::Interchanges::FiveOhOne::ElementDefs::SeparatorElementVal, Stupidedi::Versions::Interchanges::FourHundred::ElementDefs::SeparatorElementVal, Stupidedi::Versions::Interchanges::FourOhOne::ElementDefs::SeparatorElementVal, Stupidedi::Versions::Interchanges::ThreeHundred::ElementDefs::SeparatorElementVal, Stupidedi::Versions::Interchanges::TwoHundred::ElementDefs::SeparatorElementVal

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractElementVal

#element?, #size

Methods inherited from AbstractVal

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

Methods included from Color

ansi, #ansi

Methods included from Inspect

#inspect

Constructor Details

#initialize(usage, position) ⇒ SimpleElementVal

Returns a new instance of SimpleElementVal.



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

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

Instance Attribute Details

#positionReader::Position (readonly)

Returns:



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

def position
  @position
end

#usageSimpleElementUse, ComponentElementUse (readonly)

Returns:

  • (SimpleElementUse, ComponentElementUse)


29
30
31
# File 'lib/stupidedi/values/simple_element_val.rb', line 29

def usage
  @usage
end

Instance Method Details

#allowed?Boolean

True unless this value isn’t included in AbstractElementUse#allowed_values

Returns:

  • (Boolean)


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

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

#component?Boolean

Returns:

  • (Boolean)


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

def component?
  @usage.component?
end

#copySimpleElementVal

Returns:



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

abstract :copy, "changes={}"

#date?Boolean

Returns:

  • (Boolean)


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

def date?
  false
end

#id?Boolean

Returns:

  • (Boolean)


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

def id?
  false
end

#leaf?Boolean

Returns true.

Returns:

  • (Boolean)

    true



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

def leaf?
  true
end

#numeric?Boolean

Returns:

  • (Boolean)


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

def numeric?
  false
end

#simple?Boolean

Returns:

  • (Boolean)


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

def simple?
  not @usage.component?
end

#string?Boolean

Returns:

  • (Boolean)


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

def string?
  false
end

#time?Boolean

Returns:

  • (Boolean)


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

def time?
  false
end

#to_x12String

Returns:



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

abstract :to_x12