Class: Artii::Figlet::Font
- Inherits:
-
Object
- Object
- Artii::Figlet::Font
- Defined in:
- lib/figlet/font.rb
Instance Attribute Summary collapse
-
#hard_blank ⇒ Object
readonly
Returns the value of attribute hard_blank.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#old_layout ⇒ Object
readonly
Returns the value of attribute old_layout.
Instance Method Summary collapse
- #[](char) ⇒ Object
- #has_char?(char) ⇒ Boolean
-
#initialize(filename, load_german = true) ⇒ Font
constructor
A new instance of Font.
- #right_to_left? ⇒ Boolean
Constructor Details
#initialize(filename, load_german = true) ⇒ Font
Returns a new instance of Font.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/figlet/font.rb', line 8 def initialize(filename, load_german = true) file = File.open(filename, 'rb') header = file.gets.strip.split(/ /) raise UnknownFontFormat if 'flf2a' != header[0][0, 5] @hard_blank = header.shift[-1, 1] @height = header.shift.to_i @baseline = header.shift @max_length = header.shift @old_layout = header.shift.to_i @comment_count = header.shift.to_i @right_to_left = header.shift @right_to_left = !@right_to_left.nil? && @right_to_left.to_i == 1 @load_german, @characters = load_german, {} load_comments file load_ascii_characters file load_german_characters file load_extended_characters file file.close end |
Instance Attribute Details
#hard_blank ⇒ Object (readonly)
Returns the value of attribute hard_blank.
42 43 44 |
# File 'lib/figlet/font.rb', line 42 def hard_blank @hard_blank end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
42 43 44 |
# File 'lib/figlet/font.rb', line 42 def height @height end |
#old_layout ⇒ Object (readonly)
Returns the value of attribute old_layout.
42 43 44 |
# File 'lib/figlet/font.rb', line 42 def old_layout @old_layout end |
Instance Method Details
#[](char) ⇒ Object
34 35 36 |
# File 'lib/figlet/font.rb', line 34 def [](char) @characters[char] end |
#has_char?(char) ⇒ Boolean
38 39 40 |
# File 'lib/figlet/font.rb', line 38 def has_char?(char) @characters.has_key? char end |
#right_to_left? ⇒ Boolean
44 45 46 |
# File 'lib/figlet/font.rb', line 44 def right_to_left? @right_to_left end |