Class: Text::Figlet::Font

Inherits:
Object
  • Object
show all
Defined in:
lib/text/figlet/font.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, load_german = true) ⇒ Font

Returns a new instance of Font.

Raises:



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/text/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_blankObject (readonly)

Returns the value of attribute hard_blank.



42
43
44
# File 'lib/text/figlet/font.rb', line 42

def hard_blank
  @hard_blank
end

#heightObject (readonly)

Returns the value of attribute height.



42
43
44
# File 'lib/text/figlet/font.rb', line 42

def height
  @height
end

#old_layoutObject (readonly)

Returns the value of attribute old_layout.



42
43
44
# File 'lib/text/figlet/font.rb', line 42

def old_layout
  @old_layout
end

Instance Method Details

#[](char) ⇒ Object



34
35
36
# File 'lib/text/figlet/font.rb', line 34

def [](char)
  @characters[char]
end

#has_char?(char) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/text/figlet/font.rb', line 38

def has_char?(char)
  @characters.has_key? char
end

#right_to_left?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/text/figlet/font.rb', line 44

def right_to_left?
  @right_to_left
end