Class: Sevgi::Graphics::Paper
- Inherits:
-
Data
- Object
- Data
- Sevgi::Graphics::Paper
- Includes:
- Comparable
- Defined in:
- lib/sevgi/graphics/auxilary/paper.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(width:, height:, unit: "mm", name: :custom) ⇒ Paper
constructor
A new instance of Paper.
- #longest ⇒ Object
- #shortest ⇒ Object
Constructor Details
#initialize(width:, height:, unit: "mm", name: :custom) ⇒ Paper
Returns a new instance of Paper.
8 9 10 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 8 def initialize(width:, height:, unit: "mm", name: :custom) super(width: Float(width), height: Float(height), unit: unit.to_sym, name: name.to_sym) end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height
5 6 7 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 5 def height @height end |
#name ⇒ Object (readonly)
Returns the value of attribute name
5 6 7 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 5 def name @name end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit
5 6 7 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 5 def unit @unit end |
#width ⇒ Object (readonly)
Returns the value of attribute width
5 6 7 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 5 def width @width end |
Class Method Details
.define(name, **spec) ⇒ Object
32 33 34 35 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 32 def self.define(name, **spec) singleton_class.attr_reader(name) instance_variable_set("@#{name}", new(name:, **spec)) end |
.define!(name) ⇒ Object
24 25 26 27 28 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 24 def self.define!(name, ...) raise ArgumentError, "Paper already defined: #{name}" if exist?(name) define(name, ...) end |
.exist?(name) ⇒ Boolean
30 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 30 def self.exist?(name) = respond_to?(name) |
Instance Method Details
#<=>(other) ⇒ Object
12 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 12 def <=>(other) = deconstruct <=> other.deconstruct |
#eql?(other) ⇒ Boolean Also known as: ==
14 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 14 def eql?(other) = self.class == other.class && deconstruct == other.deconstruct |
#hash ⇒ Object
16 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 16 def hash = [self.class, *deconstruct].hash |
#longest ⇒ Object
18 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 18 def longest = [width, height].max |
#shortest ⇒ Object
20 |
# File 'lib/sevgi/graphics/auxilary/paper.rb', line 20 def shortest = [width, height].min |