Class: Cabriolet::Models::HLPTopic

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

Overview

QuickHelp topic model

Represents a single topic in a QuickHelp help database. Each topic contains formatted text lines with styles and hyperlinks.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index: 0, offset: 0, size: 0) ⇒ HLPTopic

Initialize a QuickHelp topic

Parameters:

  • index (Integer) (defaults to: 0)

    Topic index in the database

  • offset (Integer) (defaults to: 0)

    Offset of topic data in file

  • size (Integer) (defaults to: 0)

    Size of compressed topic data



17
18
19
20
21
22
23
24
# File 'lib/cabriolet/models/hlp_file.rb', line 17

def initialize(index: 0, offset: 0, size: 0)
  @index = index
  @offset = offset
  @size = size
  @lines = []
  @source_data = nil
   = {}
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def index
  @index
end

#linesObject

Returns the value of attribute lines.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def lines
  @lines
end

#metadataObject

Returns the value of attribute metadata.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def 
  
end

#offsetObject

Returns the value of attribute offset.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def offset
  @offset
end

#sizeObject

Returns the value of attribute size.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def size
  @size
end

#source_dataObject

Returns the value of attribute source_data.



10
11
12
# File 'lib/cabriolet/models/hlp_file.rb', line 10

def source_data
  @source_data
end

Instance Method Details

#add_line(line) ⇒ void

This method returns an undefined value.

Add a line to the topic

Parameters:



44
45
46
# File 'lib/cabriolet/models/hlp_file.rb', line 44

def add_line(line)
  @lines << line
end

#empty?Boolean

Check if topic has any content

Returns:

  • (Boolean)

    true if topic has lines



29
30
31
# File 'lib/cabriolet/models/hlp_file.rb', line 29

def empty?
  @lines.empty?
end

#plain_textString

Get plain text content (without formatting)

Returns:

  • (String)

    plain text of all lines



36
37
38
# File 'lib/cabriolet/models/hlp_file.rb', line 36

def plain_text
  @lines.map(&:text).join("\n")
end