Class: Languages::Epl2::Font

Inherits:
Object
  • Object
show all
Defined in:
lib/languages/epl2/font.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Font

Returns a new instance of Font.



6
7
8
9
10
11
12
13
# File 'lib/languages/epl2/font.rb', line 6

def initialize(opts = {})
  # defaults
  @name     = opts[:name] || "2"
  @rotation = opts.include?(:rotation) ? font_rotation(opts[:rotation]) : font_rotation(:by_0)
  @height   = opts[:height] || 1
  @width    = opts[:width] || 1
  @name, @height, @width = font_size(opts[:size]) if opts.include?(:size)
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



4
5
6
# File 'lib/languages/epl2/font.rb', line 4

def height
  @height
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/languages/epl2/font.rb', line 4

def name
  @name
end

#rotationObject (readonly)

Returns the value of attribute rotation.



4
5
6
# File 'lib/languages/epl2/font.rb', line 4

def rotation
  @rotation
end

#widthObject (readonly)

Returns the value of attribute width.



4
5
6
# File 'lib/languages/epl2/font.rb', line 4

def width
  @width
end

Instance Method Details

#font_rotation(amount) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/languages/epl2/font.rb', line 30

def font_rotation(amount)
@rotation = case(amount)
                    when :by_90
                      1
                    when :by_180
                      2
                    when :by_270
                      3
                    else
                      0
                    end        
end

#font_size(val) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/languages/epl2/font.rb', line 15

def font_size(val)
  case val
  when :normal
    [2,1,1]
  when :small
    [1,1,1]
  when :large
    [3,1,1]
  when :x_large
    [4,1,1]
  else
    [2,1,1]
  end
end

#renderObject



42
43
44
# File 'lib/languages/epl2/font.rb', line 42

def render
  ""
end