Class: Prune::Fonts::Base

Inherits:
Object
  • Object
show all
Includes:
Elements, Errors, PObjects
Defined in:
lib/prune/fonts/base.rb

Direct Known Subclasses

BaseEn, BaseJa

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PObjects

pa, pd, ph, pl, pn, ps

Constructor Details

#initialize(document) ⇒ Base

Initialize.



35
36
37
38
39
# File 'lib/prune/fonts/base.rb', line 35

def initialize(document)
  @document = document
  @main_element = nil
  @font_name = self.class.font_name
end

Instance Attribute Details

#font_nameObject (readonly)

Returns the value of attribute font_name.



32
33
34
# File 'lib/prune/fonts/base.rb', line 32

def font_name
  @font_name
end

Class Method Details

.bold?(options) ⇒ Boolean

Check bold flag.

Returns:

  • (Boolean)

Raises:



12
13
14
15
16
# File 'lib/prune/fonts/base.rb', line 12

def bold?(options)
  raise FontOptionError unless
    [true, false, nil].include?(options[:bold])
  options[:bold] || false
end

.font_nameObject

Get font name.



26
27
28
29
# File 'lib/prune/fonts/base.rb', line 26

def font_name
  class_name = self.to_s.gsub(/\A.*::/, "")
  class_name.gsub(/\A(.)/){$1.downcase}.gsub(/([A-Z])/){"_#{$1.downcase}"}
end

.italic?(options) ⇒ Boolean

Check italic flag.

Returns:

  • (Boolean)

Raises:



19
20
21
22
23
# File 'lib/prune/fonts/base.rb', line 19

def italic?(options)
  raise FontOptionError unless
    [true, false, nil].include?(options[:italic])
  options[:italic] || false
end

Instance Method Details

#encodingObject

Get encoding of the font.



52
53
54
# File 'lib/prune/fonts/base.rb', line 52

def encoding
  @main_element.encoding
end

#font_symObject

Get font symbol.



57
58
59
# File 'lib/prune/fonts/base.rb', line 57

def font_sym
  @font_name.to_sym
end

#nameObject

Get name of the font.



47
48
49
# File 'lib/prune/fonts/base.rb', line 47

def name
  @main_element.name
end

#referenceObject

Get reference of the font.



42
43
44
# File 'lib/prune/fonts/base.rb', line 42

def reference
  @main_element.reference
end