Class: AtlasEngine::AddressValidation::Candidate::Component

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
app/models/atlas_engine/address_validation/candidate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ Component

Returns a new instance of Component.



80
81
82
83
# File 'app/models/atlas_engine/address_validation/candidate.rb', line 80

def initialize(name, value)
  @name = name
  @value = value
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



70
71
72
# File 'app/models/atlas_engine/address_validation/candidate.rb', line 70

def name
  @name
end

#sequencesObject



90
91
92
# File 'app/models/atlas_engine/address_validation/candidate.rb', line 90

def sequences
  @sequences ||= values.map { |val| AtlasEngine::AddressValidation::Token::Sequence.from_string(val) }
end

#valueObject

Returns the value of attribute value.



72
73
74
# File 'app/models/atlas_engine/address_validation/candidate.rb', line 72

def value
  @value
end

Instance Method Details

#first_valueObject



85
86
87
# File 'app/models/atlas_engine/address_validation/candidate.rb', line 85

def first_value
  values.first
end

#serializeObject



95
96
97
98
99
100
101
# File 'app/models/atlas_engine/address_validation/candidate.rb', line 95

def serialize
  if value.is_a?(Array)
    "[#{value.map(&:to_s).join(",")}]"
  else
    value.to_s
  end
end

#valuesObject



104
105
106
# File 'app/models/atlas_engine/address_validation/candidate.rb', line 104

def values
  Array(value)
end