Class: Rabbit::Size

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbit/size.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_width, base_height, width, height, ratio) ⇒ Size

Returns a new instance of Size.


32
33
34
35
36
37
38
39
# File 'lib/rabbit/size.rb', line 32

def initialize(base_width, base_height, width, height, ratio)
  @base_width = base_width
  @base_height = base_height
  @real_width = width
  @real_height = height
  @ratio = ratio
  compute_logical_size
end

Instance Attribute Details

#base_heightObject (readonly)

Returns the value of attribute base_height.


20
21
22
# File 'lib/rabbit/size.rb', line 20

def base_height
  @base_height
end

#base_widthObject (readonly)

Returns the value of attribute base_width.


19
20
21
# File 'lib/rabbit/size.rb', line 19

def base_width
  @base_width
end

#logical_heightObject (readonly)

Returns the value of attribute logical_height.


26
27
28
# File 'lib/rabbit/size.rb', line 26

def logical_height
  @logical_height
end

#logical_margin_bottomObject (readonly)

Returns the value of attribute logical_margin_bottom.


30
31
32
# File 'lib/rabbit/size.rb', line 30

def logical_margin_bottom
  @logical_margin_bottom
end

#logical_margin_leftObject (readonly)

Returns the value of attribute logical_margin_left.


27
28
29
# File 'lib/rabbit/size.rb', line 27

def logical_margin_left
  @logical_margin_left
end

#logical_margin_rightObject (readonly)

Returns the value of attribute logical_margin_right.


28
29
30
# File 'lib/rabbit/size.rb', line 28

def logical_margin_right
  @logical_margin_right
end

#logical_margin_topObject (readonly)

Returns the value of attribute logical_margin_top.


29
30
31
# File 'lib/rabbit/size.rb', line 29

def logical_margin_top
  @logical_margin_top
end

#logical_widthObject (readonly)

Returns the value of attribute logical_width.


25
26
27
# File 'lib/rabbit/size.rb', line 25

def logical_width
  @logical_width
end

#ratioObject (readonly)

Returns the value of attribute ratio.


31
32
33
# File 'lib/rabbit/size.rb', line 31

def ratio
  @ratio
end

#real_content_heightObject (readonly)

Returns the value of attribute real_content_height.


24
25
26
# File 'lib/rabbit/size.rb', line 24

def real_content_height
  @real_content_height
end

#real_content_widthObject (readonly)

Returns the value of attribute real_content_width.


23
24
25
# File 'lib/rabbit/size.rb', line 23

def real_content_width
  @real_content_width
end

#real_heightObject (readonly)

Returns the value of attribute real_height.


22
23
24
# File 'lib/rabbit/size.rb', line 22

def real_height
  @real_height
end

#real_widthObject (readonly)

Returns the value of attribute real_width.


21
22
23
# File 'lib/rabbit/size.rb', line 21

def real_width
  @real_width
end

Instance Method Details

#have_logical_margin?Boolean

Returns:

  • (Boolean)

51
52
53
# File 'lib/rabbit/size.rb', line 51

def have_logical_margin?
  have_logical_margin_x? or have_logical_margin_y?
end

#have_logical_margin_x?Boolean

Returns:

  • (Boolean)

41
42
43
44
# File 'lib/rabbit/size.rb', line 41

def have_logical_margin_x?
  @logical_margin_left > 0 or
    @logical_margin_right > 0
end

#have_logical_margin_y?Boolean

Returns:

  • (Boolean)

46
47
48
49
# File 'lib/rabbit/size.rb', line 46

def have_logical_margin_y?
  @logical_margin_top > 0 or
    @logical_margin_bottom > 0
end

#logical_scaleObject


55
56
57
# File 'lib/rabbit/size.rb', line 55

def logical_scale
  @logical_scale
end