Class: VivlioStarter::CLI::IndexCommands::MainReference

Inherits:
Data
  • Object
show all
Defined in:
lib/vivlio_starter/cli/index/main_reference.rb

Overview

main: の 1 要素

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#chapterObject (readonly)

Returns the value of attribute chapter

Returns:

  • (Object)

    the current value of chapter



24
25
26
# File 'lib/vivlio_starter/cli/index/main_reference.rb', line 24

def chapter
  @chapter
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



24
25
26
# File 'lib/vivlio_starter/cli/index/main_reference.rb', line 24

def path
  @path
end

Class Method Details

.parse(value) ⇒ Object

Parameters:

  • value (String)

    例 "21#Markdown とは"



26
27
28
29
# File 'lib/vivlio_starter/cli/index/main_reference.rb', line 26

def self.parse(value)
  chapter, *path = value.to_s.split('#')
  new(chapter: chapter.to_s.strip, path: path.map(&:strip).reject(&:empty?))
end

Instance Method Details

#section?Boolean

Returns:

  • (Boolean)


34
# File 'lib/vivlio_starter/cli/index/main_reference.rb', line 34

def section? = path.any?

#to_sObject

辞書へ書き戻す形(著者が書いたとおりに保つ)



32
# File 'lib/vivlio_starter/cli/index/main_reference.rb', line 32

def to_s = ([chapter] + path).join('#')