Class: Libgeo::Formatter
- Inherits:
-
Object
- Object
- Libgeo::Formatter
- Defined in:
- lib/libgeo/formatter.rb,
lib/libgeo/formatter/compiler.rb,
lib/libgeo/formatter/evaluator.rb
Overview
Class: coordinate formatter
Compiles sprintf-like patterns and present given Coordinate as a DMS string
Example:
coord = Latitude.new(:N, 48, 4, 15.7)
my_format = Formatter.new('%H%d°%2M′')
my_format.format(coord) # => 'N48°04.26306′'
Defined Under Namespace
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Source pattern.
Instance Method Summary collapse
-
#format(coordinate, evaluator = Evaluator) ⇒ Object
Create new string representing coordinate.
-
#inspect ⇒ Object
(also: #to_s, #pretty_inspect)
Represent instance as string.
Instance Attribute Details
#pattern ⇒ Object (readonly)
Source pattern
26 27 28 |
# File 'lib/libgeo/formatter.rb', line 26 def pattern @pattern end |
Instance Method Details
#format(coordinate, evaluator = Evaluator) ⇒ Object
Create new string representing coordinate
Params:
- coordinate Latitude|Longitude source coordinate
- evaluator Class private
Returns: String formatted string
37 38 39 |
# File 'lib/libgeo/formatter.rb', line 37 def format(coordinate, evaluator=Evaluator) evaluator.new(coordinate).instance_eval(expression) end |
#inspect ⇒ Object Also known as: to_s, pretty_inspect
Represent instance as string
44 45 46 |
# File 'lib/libgeo/formatter.rb', line 44 def inspect "#<Libgeo::Formatter pattern=(#{pattern})>" end |