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

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



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

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

Instance Attribute Details

#positionReader::Position (readonly)

Returns:



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

def position
  @position
end

#usageSimpleElementUse, ComponentElementUse (readonly)

Returns:

  • (SimpleElementUse, ComponentElementUse)


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

def usage
  @usage
end

Instance Method Details

#allowed?Boolean

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

Returns:

  • (Boolean)


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

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

#component?Boolean

Returns:

  • (Boolean)


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

def component?
  @usage.component?
end

#copySimpleElementVal

Returns:



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

abstract :copy, "changes={}"

#date?Boolean

Returns:

  • (Boolean)


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

def date?
  false
end

#id?Boolean

Returns:

  • (Boolean)


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

def id?
  false
end

#leaf?Boolean

Returns true

Returns:

  • (Boolean)

    true



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

def leaf?
  true
end

#numeric?Boolean

Returns:

  • (Boolean)


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

def numeric?
  false
end

#simple?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/stupidedi/values/simple_element_val.rb', line 79

def simple?
  not @usage.component?
end

#string?Boolean

Returns:

  • (Boolean)


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

def string?
  false
end

#time?Boolean

Returns:

  • (Boolean)


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

def time?
  false
end

#to_x12String

Returns:

  • (String)


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

abstract :to_x12