Class: Squib::Args::ScaleBox Private

Inherits:
Object
  • Object
show all
Includes:
ArgLoader
Defined in:
lib/squib/args/scale_box.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ArgLoader

#[], #convert_units, #defaultify, #expand_and_set_and_defaultify, #expandable_singleton?, #load!, #prep_layout_args, #validate

Constructor Details

#initialize(deck) ⇒ ScaleBox

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ScaleBox.



10
11
12
# File 'lib/squib/args/scale_box.rb', line 10

def initialize(deck)
  @deck = deck
end

Class Method Details

.expanding_parametersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
# File 'lib/squib/args/scale_box.rb', line 20

def self.expanding_parameters
  parameters.keys # all of them
end

.parametersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
17
18
# File 'lib/squib/args/scale_box.rb', line 14

def self.parameters
  { x: 0, y: 0,
    width: :native, height: :native
  }
end

.params_with_unitsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/squib/args/scale_box.rb', line 24

def self.params_with_units
  parameters.keys # all of them
end

Instance Method Details

#validate_height(arg, i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
42
43
44
45
46
47
48
# File 'lib/squib/args/scale_box.rb', line 39

def validate_height(arg, i)
  return @deck.height if arg.to_s == 'deck'
  return :native      if arg.to_s == 'native'
  return arg          if arg.respond_to? :to_f
  if arg.to_s == 'scale'
    raise 'if height is \'scale\', width must be a number' unless width[i].respond_to? :to_f
    return arg
  end
  raise 'height must be a number, :scale, :native, or :deck'
end

#validate_width(arg, i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
31
32
33
34
35
36
37
# File 'lib/squib/args/scale_box.rb', line 28

def validate_width(arg, i)
  return @deck.width if arg.to_s == 'deck'
  return :native     if arg.to_s == 'native'
  return arg         if arg.respond_to? :to_f
  if arg.to_s == 'scale'
    raise 'if width is :scale, height must be a number' unless height[i].respond_to? :to_f
    return arg
  end
  raise 'width must be a number, :scale, :native, or :deck'
end