Class: Hokusai::Clamping::Group
- Inherits:
-
Object
- Object
- Hokusai::Clamping::Group
- Defined in:
- ui/src/hokusai/font.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #bold? ⇒ Boolean
- #chars ⇒ Object
- #code? ⇒ Boolean
- #each_char ⇒ Object
-
#initialize(raw) ⇒ Group
constructor
A new instance of Group.
- #italics? ⇒ Boolean
- #link ⇒ Object
- #link? ⇒ Boolean
- #normal? ⇒ Boolean
- #offset ⇒ Object
- #size ⇒ Object
- #type ⇒ Object
- #width ⇒ Object
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
#raw ⇒ Object (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
59 60 61 |
# File 'ui/src/hokusai/font.rb', line 59 def bold? @bold ||= ((type & LibHokusai::GROUP_BOLD) != 0) end |
#chars ⇒ Object
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
71 72 73 |
# File 'ui/src/hokusai/font.rb', line 71 def code? @code ||= type & LibHokusai::GROUP_CODE end |
#each_char ⇒ Object
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
63 64 65 |
# File 'ui/src/hokusai/font.rb', line 63 def italics? @italics ||= ((type & LibHokusai::GROUP_ITALICS) != 0) end |
#link ⇒ Object
75 76 77 |
# File 'ui/src/hokusai/font.rb', line 75 def link @href ||= raw[:payload].read_string end |
#link? ⇒ Boolean
67 68 69 |
# File 'ui/src/hokusai/font.rb', line 67 def link? @link ||= ((type & LibHokusai::GROUP_LINK) != 0) end |
#normal? ⇒ Boolean
55 56 57 |
# File 'ui/src/hokusai/font.rb', line 55 def normal? @normal ||= type == LibHokusai::GROUP_NORMAL end |
#offset ⇒ Object
39 40 41 |
# File 'ui/src/hokusai/font.rb', line 39 def offset @offset ||= raw[:offset] end |
#size ⇒ Object
43 44 45 |
# File 'ui/src/hokusai/font.rb', line 43 def size @size ||= raw[:size] end |
#type ⇒ Object
51 52 53 |
# File 'ui/src/hokusai/font.rb', line 51 def type @type ||= raw[:type] end |
#width ⇒ Object
47 48 49 |
# File 'ui/src/hokusai/font.rb', line 47 def width chars.sum(&:width) end |