Class: Coradoc::Element::Block::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/element/block/core.rb

Direct Known Subclasses

Example, Literal, Quote, Side, SourceCode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, options = {}) ⇒ Core

Returns a new instance of Core.



9
10
11
12
13
14
15
16
17
18
# File 'lib/coradoc/element/block/core.rb', line 9

def initialize(title, options = {})
  @title = title
  @lines = options.fetch(:lines, [])
  @type_str = options.fetch(:type, nil)
  @delimiter = options.fetch(:delimiter, "")
  @attributes = options.fetch(:attributes, {})
  @lang = options.fetch(:lang, nil)
  @id = options.fetch(:id, nil)
  @anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



7
8
9
# File 'lib/coradoc/element/block/core.rb', line 7

def attributes
  @attributes
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/coradoc/element/block/core.rb', line 7

def id
  @id
end

#langObject (readonly)

Returns the value of attribute lang.



7
8
9
# File 'lib/coradoc/element/block/core.rb', line 7

def lang
  @lang
end

#linesObject (readonly)

Returns the value of attribute lines.



7
8
9
# File 'lib/coradoc/element/block/core.rb', line 7

def lines
  @lines
end

#titleObject (readonly)

Returns the value of attribute title.



7
8
9
# File 'lib/coradoc/element/block/core.rb', line 7

def title
  @title
end

Instance Method Details

#gen_anchorObject



24
25
26
# File 'lib/coradoc/element/block/core.rb', line 24

def gen_anchor
  @anchor.nil? ? "" : "#{@anchor.to_adoc}\n"
end

#gen_attributesObject



34
35
36
# File 'lib/coradoc/element/block/core.rb', line 34

def gen_attributes
  @attributes.nil? ? "" : "#{@attributes.to_adoc}\n"
end

#gen_delimiterObject



38
39
40
# File 'lib/coradoc/element/block/core.rb', line 38

def gen_delimiter
  @delimiter_char * @delimiter_len
end

#gen_linesObject



42
43
44
# File 'lib/coradoc/element/block/core.rb', line 42

def gen_lines
  Coradoc::Generator.gen_adoc(@lines)
end

#gen_titleObject



28
29
30
31
32
# File 'lib/coradoc/element/block/core.rb', line 28

def gen_title
  t = Coradoc::Generator.gen_adoc(@title)
  return "" if t.empty?
  ".#{t}\n"
end

#typeObject



20
21
22
# File 'lib/coradoc/element/block/core.rb', line 20

def type
  @type ||= defined_type || type_from_delimiter
end