Class: Stupidedi::Versions::Common::ElementTypes::StringVal::NonEmpty
- Inherits:
-
Valid
- Object
- Stupidedi::Values::AbstractVal
- Stupidedi::Values::AbstractElementVal
- Stupidedi::Values::SimpleElementVal
- Stupidedi::Versions::Common::ElementTypes::StringVal
- Valid
- Stupidedi::Versions::Common::ElementTypes::StringVal::NonEmpty
- Defined in:
- lib/stupidedi/versions/common/element_types/an.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- #value ⇒ String readonly
Attributes inherited from Stupidedi::Values::SimpleElementVal
Instance Method Summary collapse
-
#initialize(string, usage, position) ⇒ NonEmpty
constructor
A new instance of NonEmpty.
-
#inspect ⇒ String
:nocov:.
- #to_date(format)
- #to_x12(truncate = true) ⇒ String
- #too_long? ⇒ Boolean
- #too_short? ⇒ Boolean
Methods inherited from Valid
#==, #coerce, #copy, #map, #valid?
Methods included from Operators::Wrappers
Methods included from Operators::Unary
Methods included from Operators::Relational
Methods inherited from Stupidedi::Versions::Common::ElementTypes::StringVal
Methods inherited from Stupidedi::Values::SimpleElementVal
#allowed?, #component?, #copy, #date?, #id?, #leaf?, #numeric?, #simple?, #string?, #time?, #to_s, #valid?
Methods inherited from Stupidedi::Values::AbstractElementVal
Methods inherited from Stupidedi::Values::AbstractVal
#blank?, #characters, #component?, #composite?, #definition, #descriptor, #element?, #empty?, #functional_group?, #interchange?, #invalid?, #leaf?, #loop?, #present?, #repeated?, #segment?, #separator?, #simple?, #size, #table?, #transaction_set?, #transmission?, #valid?
Methods included from Color
Constructor Details
#initialize(string, usage, position) ⇒ NonEmpty
Returns a new instance of NonEmpty.
296 297 298 299 |
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 296 def initialize(string, usage, position) @value = string super(usage, position) end |
Instance Attribute Details
#value ⇒ String (readonly)
294 295 296 |
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 294 def value @value end |
Instance Method Details
#inspect ⇒ String
:nocov:
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 317 def inspect id = definition.bind do |d| "[#{"% 5s" % d.id}: #{d.name}]".bind do |s| if usage.forbidden? ansi.forbidden(s) elsif usage.required? ansi.required(s) else ansi.optional(s) end end end ansi.element("AN.value#{id}") + "(#{@value})" end |
#to_date(format)
335 336 337 |
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 335 def to_date(format) AN.strptime(format, @value) end |
#to_x12(truncate = true) ⇒ String
310 311 312 313 |
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 310 def to_x12(truncate = true) x12 = @value.ljust(definition.min_length, " ") truncate ? x12.take(definition.max_length) : x12 end |
#too_long? ⇒ Boolean
301 302 303 |
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 301 def too_long? @value.lstrip.length > definition.max_length end |
#too_short? ⇒ Boolean
305 306 307 |
# File 'lib/stupidedi/versions/common/element_types/an.rb', line 305 def too_short? @value.lstrip.length < definition.min_length end |