Class: Hokusai::Clamping::Group

Inherits:
Object
  • Object
show all
Defined in:
ui/src/hokusai/font.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Group

Returns a new instance of Group.



35
36
37
# File 'ui/src/hokusai/font.rb', line 35

def initialize(raw)
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



33
34
35
# File 'ui/src/hokusai/font.rb', line 33

def raw
  @raw
end

Instance Method Details

#bold?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'ui/src/hokusai/font.rb', line 59

def bold?
  @bold ||= ((type & LibHokusai::GROUP_BOLD) != 0)
end

#charsObject



79
80
81
82
83
84
85
86
87
88
# File 'ui/src/hokusai/font.rb', line 79

def chars
  return @chars unless @chars.nil?

  @chars = []
  each_char do |char|
    @chars << char
  end

  @chars
end

#code?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'ui/src/hokusai/font.rb', line 71

def code?
  @code ||= type & LibHokusai::GROUP_CODE
end

#each_charObject



90
91
92
93
94
95
96
97
98
99
# File 'ui/src/hokusai/font.rb', line 90

def each_char
  char = raw[:chars]
  i = 0

  while !char.null?
    yield Char.new(char), i
    i += 1
    char = char[:next_char]
  end
end

#italics?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'ui/src/hokusai/font.rb', line 63

def italics?
  @italics ||= ((type & LibHokusai::GROUP_ITALICS) != 0)
end


75
76
77
# File 'ui/src/hokusai/font.rb', line 75

def link
  @href ||= raw[:payload].read_string
end

#link?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'ui/src/hokusai/font.rb', line 67

def link?
  @link ||= ((type & LibHokusai::GROUP_LINK) != 0)
end

#normal?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'ui/src/hokusai/font.rb', line 55

def normal?
  @normal ||= type == LibHokusai::GROUP_NORMAL
end

#offsetObject



39
40
41
# File 'ui/src/hokusai/font.rb', line 39

def offset
  @offset ||= raw[:offset]
end

#sizeObject



43
44
45
# File 'ui/src/hokusai/font.rb', line 43

def size
  @size ||= raw[:size]
end

#typeObject



51
52
53
# File 'ui/src/hokusai/font.rb', line 51

def type
  @type ||= raw[:type]
end

#widthObject



47
48
49
# File 'ui/src/hokusai/font.rb', line 47

def width
  chars.sum(&:width)
end