Class: Vivlio::Starter::CLI::TocCommands::Heading

Inherits:
Struct
  • Object
show all
Defined in:
lib/vivlio/starter/cli/toc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#css_classObject

Returns the value of attribute css_class

Returns:

  • (Object)

    the current value of css_class



316
317
318
# File 'lib/vivlio/starter/cli/toc.rb', line 316

def css_class
  @css_class
end

#hrefObject

Returns the value of attribute href

Returns:

  • (Object)

    the current value of href



316
317
318
# File 'lib/vivlio/starter/cli/toc.rb', line 316

def href
  @href
end

#levelObject

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



316
317
318
# File 'lib/vivlio/starter/cli/toc.rb', line 316

def level
  @level
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



316
317
318
# File 'lib/vivlio/starter/cli/toc.rb', line 316

def text
  @text
end

Instance Method Details

#list_markupObject

見出し情報から TOC 用の <li> 文字列を生成する<a> タグを使用してクリックで該当ページへジャンプ可能にする



319
320
321
322
323
324
325
# File 'lib/vivlio/starter/cli/toc.rb', line 319

def list_markup
  if href && !href.empty?
    %(<li class="#{css_class}"><a href="#{href}" class="toc-title"><span class="toc-label">#{text}</span></a>)
  else
    %(<li class="#{css_class}"><span class="toc-title"><span class="toc-label">#{text}</span></span>)
  end
end