Class: AIXM::R
Overview
Rectangle shape composed of two lengths
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Rectangle length.
-
#width ⇒ Object
readonly
Rectangle width.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(length, width = nil) ⇒ R
constructor
See the overview for examples.
- #inspect ⇒ String
-
#surface ⇒ Float
Calculate the surface in square meters.
-
#to_s ⇒ String
Human readable representation (e.g. “25.0 m x 20.0 m”).
Methods included from Concerns::HashEquality
Constructor Details
Instance Attribute Details
Instance Method Details
#==(other) ⇒ Object
60 61 62 |
# File 'lib/aixm/r.rb', line 60 def ==(other) self.class === other && length == other.length && width == other.width end |
#inspect ⇒ String
35 36 37 |
# File 'lib/aixm/r.rb', line 35 def inspect %Q(#<#{self.class} #{to_s}>) end |
#surface ⇒ Float
Calculate the surface in square meters.
55 56 57 |
# File 'lib/aixm/r.rb', line 55 def surface length.to_m.dim * width.to_m.dim end |
#to_s ⇒ String
Returns human readable representation (e.g. “25.0 m x 20.0 m”).
40 41 42 |
# File 'lib/aixm/r.rb', line 40 def to_s [length, width].join(' x ') end |