Class: Carta::CLI::Book

Inherits:
Object
  • Object
show all
Defined in:
lib/carta/cli/book.rb

Overview

This is our book generator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thor, meta) ⇒ Book

Returns a new instance of Book.



6
7
8
9
10
# File 'lib/carta/cli/book.rb', line 6

def initialize(thor, meta)
  @thor = thor
  @meta = meta
  @book_name = (meta[:title].is_a? String) ? meta[:title] : meta[:title].join(' ')
end

Instance Attribute Details

#book_nameObject (readonly)

Returns the value of attribute book_name.



4
5
6
# File 'lib/carta/cli/book.rb', line 4

def book_name
  @book_name
end

#metaObject (readonly)

Returns the value of attribute meta.



4
5
6
# File 'lib/carta/cli/book.rb', line 4

def meta
  @meta
end

#thorObject (readonly)

Returns the value of attribute thor.



4
5
6
# File 'lib/carta/cli/book.rb', line 4

def thor
  @thor
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
# File 'lib/carta/cli/book.rb', line 12

def run
  require 'carta/cli/chapter'
  thor.directory 'ebook', book_name
  thor.inside book_name do
    Carta::CLI::Chapter.new(thor, 0, "My First #{book_name} Chapter").run
  end
end