Class: Atelier::Library

Inherits:
Object
  • Object
show all
Includes:
LibraryDSL
Defined in:
lib/atelier/library.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LibraryDSL

#description, #title

Constructor Details

#initialize(name, &block) ⇒ Library

Returns a new instance of Library.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/atelier/library.rb', line 11

def initialize(name, &block)
  @name = name
  @title = ''
  @description = ''
  @libraries = {}
  @actions = {
    libraries: :default,
    actions: :default,
    help: :default
  }
  instance_eval &block
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/atelier/library.rb', line 9

def name
  @name
end

Instance Method Details

#actionsObject



29
30
31
32
# File 'lib/atelier/library.rb', line 29

def actions
  @actions.each { |action_name, action| puts action_name }
  @actions
end

#helpObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/atelier/library.rb', line 34

def help
  puts "#{name}: #{title}"

  puts 'default actions:'
  @actions.each do |action_name, action|
    puts "  - #{name} #{action_name}" if action == :default
  end

  puts 'actions:'
  @actions.each do |action_name, action|
    puts "  - #{name} #{action_name} #{action.synopsis}" unless action == :default
  end
end

#librariesObject



24
25
26
27
# File 'lib/atelier/library.rb', line 24

def libraries
  @libraries.each { |lib_name, lib| puts lib_name }
  @libraries
end