Class: Figlet::Font

Inherits:
Object
  • Object
show all
Defined in:
lib/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:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/figlet/font.rb', line 6

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.



40
41
42
# File 'lib/figlet/font.rb', line 40

def hard_blank
  @hard_blank
end

#heightObject (readonly)

Returns the value of attribute height.



40
41
42
# File 'lib/figlet/font.rb', line 40

def height
  @height
end

#old_layoutObject (readonly)

Returns the value of attribute old_layout.



40
41
42
# File 'lib/figlet/font.rb', line 40

def old_layout
  @old_layout
end

Instance Method Details

#[](char) ⇒ Object



32
33
34
# File 'lib/figlet/font.rb', line 32

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

#has_char?(char) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/figlet/font.rb', line 36

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

#right_to_left?Boolean

Returns:

  • (Boolean)


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

def right_to_left?
  @right_to_left
end