Class: Sapristi::Definition
- Inherits:
-
Object
- Object
- Sapristi::Definition
- Defined in:
- lib/sapristi/definition.rb
Constant Summary collapse
- TRANSLATIONS =
{ 'H-size' => 'work_area_width', 'V-size' => 'work_area_height', 'X-position' => 'work_area_width', 'Y-position' => 'work_area_height' }.freeze
- NUMERIC_FIELDS =
(TRANSLATIONS.keys + %w[Workspace]).freeze
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#h_size ⇒ Object
readonly
Returns the value of attribute h_size.
-
#monitor ⇒ Object
readonly
Returns the value of attribute monitor.
-
#raw_definition ⇒ Object
readonly
Returns the value of attribute raw_definition.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#v_size ⇒ Object
readonly
Returns the value of attribute v_size.
-
#workspace ⇒ Object
readonly
Returns the value of attribute workspace.
-
#x_position ⇒ Object
readonly
Returns the value of attribute x_position.
-
#y_position ⇒ Object
readonly
Returns the value of attribute y_position.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(definition_hash) ⇒ Definition
constructor
A new instance of Definition.
- #to_s ⇒ Object
Constructor Details
#initialize(definition_hash) ⇒ Definition
Returns a new instance of Definition.
11 12 13 14 15 16 17 18 |
# File 'lib/sapristi/definition.rb', line 11 def initialize(definition_hash) validate_raw definition_hash @raw_definition = definition_hash.to_h.clone @monitor = MonitorManager.new.get_monitor_or_main definition_hash['Monitor'] @workspace = WindowManager.new.find_workspace_or_current definition_hash['Workspace']&.to_i normalize_variables end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
24 25 26 |
# File 'lib/sapristi/definition.rb', line 24 def command @command end |
#h_size ⇒ Object (readonly)
Returns the value of attribute h_size.
24 25 26 |
# File 'lib/sapristi/definition.rb', line 24 def h_size @h_size end |
#monitor ⇒ Object (readonly)
Returns the value of attribute monitor.
24 25 26 |
# File 'lib/sapristi/definition.rb', line 24 def monitor @monitor end |
#raw_definition ⇒ Object (readonly)
Returns the value of attribute raw_definition.
24 25 26 |
# File 'lib/sapristi/definition.rb', line 24 def raw_definition @raw_definition end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
24 25 26 |
# File 'lib/sapristi/definition.rb', line 24 def title @title end |
#v_size ⇒ Object (readonly)
Returns the value of attribute v_size.
24 25 26 |
# File 'lib/sapristi/definition.rb', line 24 def v_size @v_size end |
#workspace ⇒ Object (readonly)
Returns the value of attribute workspace.
24 25 26 |
# File 'lib/sapristi/definition.rb', line 24 def workspace @workspace end |
#x_position ⇒ Object (readonly)
Returns the value of attribute x_position.
24 25 26 |
# File 'lib/sapristi/definition.rb', line 24 def x_position @x_position end |
#y_position ⇒ Object (readonly)
Returns the value of attribute y_position.
24 25 26 |
# File 'lib/sapristi/definition.rb', line 24 def y_position @y_position end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
30 31 32 |
# File 'lib/sapristi/definition.rb', line 30 def ==(other) other.class == self.class && state == other.state end |
#hash ⇒ Object
26 27 28 |
# File 'lib/sapristi/definition.rb', line 26 def hash state.hash end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/sapristi/definition.rb', line 20 def to_s HEADERS.map { |key| "#{key}: #{raw_definition[key]}" }.join(', ') end |