Class: Page
Instance Method Summary collapse
- #apply_orientation(which = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Page
constructor
A new instance of Page.
- #sizes ⇒ Object
Methods inherited from Area
Methods included from Context
Constructor Details
#initialize(options = {}) ⇒ Page
Returns a new instance of Page.
2 3 4 5 6 7 |
# File 'lib/context/areas/page.rb', line 2 def initialize(={}) set_size([:size] || :standard) apply_orientation([:orient] || [:orientation] || :landscape) [:size] = apply_orientation if @orientation super([0,0], ) end |
Instance Method Details
#apply_orientation(which = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/context/areas/page.rb', line 9 def apply_orientation which=nil case which when :portrait size[:height] = size[:long] if size[:long] size[:width] = size[:short] if size[:short] when :landscape size[:height] = size[:short] if size[:short] size[:width] = size[:long] if size[:long] else raise 'orientation must be either portrait or landscape' end if size[:height] && size[:width] size[:height] = size[:height].to_f size[:width] = size[:width].to_f else raise 'need to set a height and width before orienting' end size end |
#sizes ⇒ Object
30 31 32 |
# File 'lib/context/areas/page.rb', line 30 def sizes {:standard => {:long => 11.0, :short => 8.5, :unit => 'inches'}} end |