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



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

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

Instance Attribute Details

#positionReader::Position (readonly)



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

def position
  @position
end

#usageSimpleElementUse, ComponentElementUse (readonly)



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

def usage
  @usage
end

Instance Method Details

#allowed?Boolean

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



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

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

#component?Boolean



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

def component?
  @usage.component?
end

#copySimpleElementVal



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

abstract :copy, "changes={}"

#date?Boolean



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

def date?
  false
end

#id?Boolean



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

def id?
  false
end

#leaf?Boolean



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

def leaf?
  true
end

#numeric?Boolean



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

def numeric?
  false
end

#simple?Boolean



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

def simple?
  not @usage.component?
end

#string?Boolean



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

def string?
  false
end

#time?Boolean



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

def time?
  false
end

#to_x12String



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

abstract :to_x12