Class: Page

Inherits:
Area show all
Defined in:
lib/context/areas/page.rb

Instance Method Summary collapse

Methods inherited from Area

#render

Methods included from Context

#header

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(options={})
  set_size(options[:size] || :standard)
  apply_orientation(options[:orient] || options[:orientation] || :landscape)
  options[:size] = apply_orientation if @orientation
  super([0,0], options)
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

#sizesObject



30
31
32
# File 'lib/context/areas/page.rb', line 30

def sizes
  {:standard => {:long => 11.0, :short => 8.5, :unit => 'inches'}}
end