Class: RRTF::ListMarker

Inherits:
Object
  • Object
show all
Defined in:
lib/rrtf/list.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, codepoint = nil) ⇒ ListMarker

Returns a new instance of ListMarker



38
39
40
41
# File 'lib/rrtf/list.rb', line 38

def initialize(name, codepoint=nil)
  @name      = name
  @codepoint = codepoint
end

Instance Method Details

#bullet?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/rrtf/list.rb', line 43

def bullet?
  !@codepoint.nil?
end

#nameObject



58
59
60
61
62
# File 'lib/rrtf/list.rb', line 58

def name
  name  = "\\{#@name\\}"
  name << '.' unless bullet?
  name
end

#number_typeObject



51
52
53
54
55
56
# File 'lib/rrtf/list.rb', line 51

def number_type
  # 23: bullet, 0: arabic
  # applies to the \levelnfcN macro
  #
  bullet? ? 23 : 0
end

#template_formatObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rrtf/list.rb', line 64

def template_format
  # The first char is the string size, the next ones are
  # either placeholders (\'0X) or actual characters to
  # include in the format. In the bullet case, \uc0 is
  # used to get rid of the multibyte translation: we want
  # an Unicode character.
  #
  # In the decimal case, we have a fixed format, with a
  # dot following the actual number.
  #
  if bullet?
    "\\'01\\uc0\\u#@codepoint"
  else
    "\\'02\\'00. "
  end
end

#text_format(n = nil) ⇒ Object



81
82
83
84
85
86
87
88
89
90
# File 'lib/rrtf/list.rb', line 81

def text_format(n=nil)
  text =
    if bullet?
      "\\uc0\\u#@codepoint"
    else
      "#{n}."
    end

  "\t#{text}\t"
end

#typeObject



47
48
49
# File 'lib/rrtf/list.rb', line 47

def type
  bullet? ? :bullet : :decimal
end