Class: Cabriolet::Models::TextAttribute

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/models/hlp_file.rb

Overview

Text attribute model

Represents style and link information for a single character.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(style = 0, link = nil) ⇒ TextAttribute

Initialize text attribute

Parameters:

  • style (Integer) (defaults to: 0)

    style flags (bold, italic, underline)

  • link (String, nil) (defaults to: nil)

    link target if any



109
110
111
112
# File 'lib/cabriolet/models/hlp_file.rb', line 109

def initialize(style = 0, link = nil)
  @style = style
  @link = link
end

Instance Attribute Details

Returns the value of attribute link.



103
104
105
# File 'lib/cabriolet/models/hlp_file.rb', line 103

def link
  @link
end

#styleObject

Returns the value of attribute style.



103
104
105
# File 'lib/cabriolet/models/hlp_file.rb', line 103

def style
  @style
end

Instance Method Details

#bold?Boolean

Check if character is bold

Returns:

  • (Boolean)

    true if bold



117
118
119
# File 'lib/cabriolet/models/hlp_file.rb', line 117

def bold?
  @style.anybits?(Binary::HLPStructures::TextStyle::BOLD)
end

#italic?Boolean

Check if character is italic

Returns:

  • (Boolean)

    true if italic



124
125
126
# File 'lib/cabriolet/models/hlp_file.rb', line 124

def italic?
  @style.anybits?(Binary::HLPStructures::TextStyle::ITALIC)
end

#linked?Boolean

Check if character has a link

Returns:

  • (Boolean)

    true if linked



138
139
140
# File 'lib/cabriolet/models/hlp_file.rb', line 138

def linked?
  !@link.nil?
end

#underline?Boolean

Check if character is underlined

Returns:

  • (Boolean)

    true if underlined



131
132
133
# File 'lib/cabriolet/models/hlp_file.rb', line 131

def underline?
  @style.anybits?(Binary::HLPStructures::TextStyle::UNDERLINE)
end