Class: Proj::Unit
- Inherits:
-
Object
- Object
- Proj::Unit
- Defined in:
- lib/proj/unit.rb
Instance Attribute Summary collapse
-
#auth_name ⇒ String
readonly
Authority name.
-
#category ⇒ String
readonly
Category of the unit: one of “linear”, “linear_per_time”, “angular”, “angular_per_time”, “scale”, “scale_per_time” or “time”.
-
#code ⇒ String
readonly
Object code.
-
#conv_factor ⇒ String
readonly
Conversion factor to apply to transform from that unit to the corresponding SI unit (metre for “linear”, radian for “angular”, etc.).
-
#deprecated ⇒ Object
readonly
Returns the value of attribute deprecated.
-
#name ⇒ String
readonly
Object name.
-
#proj_short_name ⇒ String
readonly
PROJ short name, like “m”, “ft”, “us-ft”, etc…
Class Method Summary collapse
-
.built_in(auth_name: nil, category: nil, allow_deprecated: false) ⇒ Object
Returns a list of built in Units.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(auth_name, code, name, category, conv_factor, proj_short_name, deprecated) ⇒ Unit
constructor
Create a new Unit.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #unit_type ⇒ Object
Constructor Details
#initialize(auth_name, code, name, category, conv_factor, proj_short_name, deprecated) ⇒ Unit
Create a new Unit
36 37 38 39 40 41 42 43 44 |
# File 'lib/proj/unit.rb', line 36 def initialize(auth_name, code, name, category, conv_factor, proj_short_name, deprecated) @auth_name = auth_name @code = code @name = name @category = category @conv_factor = conv_factor @proj_short_name = proj_short_name @deprecated = deprecated end |
Instance Attribute Details
#auth_name ⇒ String (readonly)
Returns Authority name.
17 18 19 |
# File 'lib/proj/unit.rb', line 17 def auth_name @auth_name end |
#category ⇒ String (readonly)
Returns Category of the unit: one of “linear”, “linear_per_time”, “angular”, “angular_per_time”, “scale”, “scale_per_time” or “time”.
17 |
# File 'lib/proj/unit.rb', line 17 attr_reader :auth_name, :code, :name, :category, :conv_factor, :proj_short_name, :deprecated |
#code ⇒ String (readonly)
Returns Object code.
17 |
# File 'lib/proj/unit.rb', line 17 attr_reader :auth_name, :code, :name, :category, :conv_factor, :proj_short_name, :deprecated |
#conv_factor ⇒ String (readonly)
Returns Conversion factor to apply to transform from that unit to the corresponding SI unit (metre for “linear”, radian for “angular”, etc.). It might be 0 in some cases to indicate no known conversion factor.
17 |
# File 'lib/proj/unit.rb', line 17 attr_reader :auth_name, :code, :name, :category, :conv_factor, :proj_short_name, :deprecated |
#deprecated ⇒ Object (readonly)
Returns the value of attribute deprecated.
17 |
# File 'lib/proj/unit.rb', line 17 attr_reader :auth_name, :code, :name, :category, :conv_factor, :proj_short_name, :deprecated |
#name ⇒ String (readonly)
Returns Object name. For example “metre”, “US survey foot”, etc.
17 |
# File 'lib/proj/unit.rb', line 17 attr_reader :auth_name, :code, :name, :category, :conv_factor, :proj_short_name, :deprecated |
#proj_short_name ⇒ String (readonly)
Returns PROJ short name, like “m”, “ft”, “us-ft”, etc… Might be nil.
17 |
# File 'lib/proj/unit.rb', line 17 attr_reader :auth_name, :code, :name, :category, :conv_factor, :proj_short_name, :deprecated |
Class Method Details
.built_in(auth_name: nil, category: nil, allow_deprecated: false) ⇒ Object
Returns a list of built in Units.
20 21 22 23 |
# File 'lib/proj/unit.rb', line 20 def self.built_in(auth_name: nil, category: nil, allow_deprecated: false) database = Database.new(Context.current) database.units(auth_name: auth_name, category: category, allow_deprecated: allow_deprecated) end |
Instance Method Details
#<=>(other) ⇒ Object
46 47 48 |
# File 'lib/proj/unit.rb', line 46 def <=>(other) self.name <=> other.name end |
#==(other) ⇒ Object
50 51 52 53 |
# File 'lib/proj/unit.rb', line 50 def ==(other) self.auth_name == other.auth_name && self.code == other.code end |
#inspect ⇒ Object
78 79 80 |
# File 'lib/proj/unit.rb', line 78 def inspect "#<#{self.class} authority=\"#{auth_name}\", code=\"#{code}\", name=\"#{name}\">" end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/proj/unit.rb', line 74 def to_s self.name end |
#unit_type ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/proj/unit.rb', line 55 def unit_type case self.category when "linear" :PJ_UT_LINEAR when "linear_per_time" :PJ_UT_LINEAR when "angular" :PJ_UT_ANGULAR when "angular_per_time" :PJ_UT_ANGULAR when "scale" :PJ_UT_SCALE when "scale_per_time" :PJ_UT_SCALE when "time" :PJ_UT_TIME end end |