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

Inherits:
Coradoc::Element::Base show all
Defined in:
lib/coradoc/element/block/core.rb

Direct Known Subclasses

Example, Literal, Pass, Quote, ReviewerComment, Side, SourceCode

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Coradoc::Element::Base

#children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit

Constructor Details

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

Returns a new instance of Core.



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

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

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#langObject

Returns the value of attribute lang.



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

def lang
  @lang
end

#linesObject

Returns the value of attribute lines.



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

def lines
  @lines
end

#titleObject

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



26
27
28
# File 'lib/coradoc/element/block/core.rb', line 26

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

#gen_attributesObject



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

def gen_attributes
  attrs = @attributes.to_adoc(false)
  return "#{attrs}\n" if !attrs.empty?

  ""
end

#gen_delimiterObject



44
45
46
# File 'lib/coradoc/element/block/core.rb', line 44

def gen_delimiter
  @delimiter_char * @delimiter_len
end

#gen_linesObject



48
49
50
# File 'lib/coradoc/element/block/core.rb', line 48

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

#gen_titleObject



30
31
32
33
34
35
# File 'lib/coradoc/element/block/core.rb', line 30

def gen_title
  t = Coradoc::Generator.gen_adoc(@title)
  return "" if t.empty?

  ".#{t}\n"
end

#typeObject



22
23
24
# File 'lib/coradoc/element/block/core.rb', line 22

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