Class: CLLI
- Inherits:
-
Object
- Object
- CLLI
- Includes:
- Cities, EntityType, ISO3166, LocationType, Pattern, Validations
- Defined in:
- lib/clli.rb,
lib/clli/cities.rb,
lib/clli/iso3166.rb,
lib/clli/pattern.rb,
lib/clli/version.rb,
lib/clli/yaml_data.rb,
lib/clli/entity_type.rb,
lib/clli/validations.rb,
lib/clli/location_type.rb
Overview
This file defines the gem version.
Defined Under Namespace
Modules: Cities, EntityType, ISO3166, LocationType, Pattern, Validations Classes: YAMLData
Constant Summary collapse
- VERSION =
'0.0.1'
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#city_name ⇒ Object
Get the name of the city this
CLLI
is located in if known. -
#country_code ⇒ Object
Get the ISO 3166 two character country code this
CLLI
is located in. -
#country_name ⇒ Object
Get the name of the country this
CLLI
is located in. -
#entity_type ⇒ Object
Get a string describing the entity code for this
CLLI
. -
#initialize(str, **options) ⇒ CLLI
constructor
Create a new
CLLI
by parsingstr
. -
#location_type ⇒ Object
Get a string describing the location code for this
CLLI
. -
#method_missing(method, *args) ⇒ Object
Allows the user to access attribute values as methods.
-
#respond_to?(method) ⇒ Boolean
Allows the user to check whether or not attributes exist.
-
#state_code ⇒ Object
Get the ISO 3166 two character state code this
CLLI
is located in. -
#state_name ⇒ Object
Get the name of the state this
CLLI
is located in.
Methods included from Cities
Methods included from ISO3166
Methods included from Validations
Methods included from LocationType
Methods included from EntityType
Methods included from Pattern
Constructor Details
#initialize(str, **options) ⇒ CLLI
Create a new CLLI
by parsing str
.
A RuntimeError is raised if the string does not represent a valid CLLI
.
Params:
str
-
the CLLI string to parse.
options
-
options which change the behavior of the parser. See
CLLI::Pattern.pattern
for more information.
47 48 49 |
# File 'lib/clli.rb', line 47 def initialize(str, **) @attributes = parse(str, ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Allows the user to access attribute values as methods.
98 99 100 101 |
# File 'lib/clli.rb', line 98 def method_missing(method, *args) return @attributes[method] if @attributes.key?(method) super end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
36 37 38 |
# File 'lib/clli.rb', line 36 def attributes @attributes end |
Instance Method Details
#city_name ⇒ Object
Get the name of the city this CLLI
is located in if known.
77 78 79 |
# File 'lib/clli.rb', line 77 def city_name self.class.city_name(place, region) end |
#country_code ⇒ Object
Get the ISO 3166 two character country code this CLLI
is located in.
65 66 67 |
# File 'lib/clli.rb', line 65 def country_code self.class.iso_country(region) end |
#country_name ⇒ Object
Get the name of the country this CLLI
is located in.
71 72 73 |
# File 'lib/clli.rb', line 71 def country_name self.class.country_name(region) end |
#entity_type ⇒ Object
Get a string describing the entity code for this CLLI
. Note, if this is not an entity CLLI
then the return value will be nil
.
92 93 94 |
# File 'lib/clli.rb', line 92 def entity_type return self.class.entity_type(entity_code) if respond_to?(:entity_code) end |
#location_type ⇒ Object
Get a string describing the location code for this CLLI
. Note, if this is an entity CLLI
then the return value will be nil
.
84 85 86 87 |
# File 'lib/clli.rb', line 84 def location_type return self.class.location_type(location_code) if respond_to?(:location_code) return self.class.location_type(customer_code) if respond_to?(:customer_code) end |
#respond_to?(method) ⇒ Boolean
Allows the user to check whether or not attributes exist.
105 106 107 108 |
# File 'lib/clli.rb', line 105 def respond_to?(method) return true if @attributes.key?(method) super end |
#state_code ⇒ Object
Get the ISO 3166 two character state code this CLLI
is located in.
53 54 55 |
# File 'lib/clli.rb', line 53 def state_code self.class.iso_state(region) end |
#state_name ⇒ Object
Get the name of the state this CLLI
is located in.
59 60 61 |
# File 'lib/clli.rb', line 59 def state_name self.class.state_name(region) end |