Class: Vita::Main
- Inherits:
-
Object
- Object
- Vita::Main
- Defined in:
- lib/vita/main.rb
Instance Attribute Summary collapse
-
#garden ⇒ Object
readonly
Returns the value of attribute garden.
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(garden, stdout) ⇒ Main
constructor
A new instance of Main.
- #join ⇒ Object
- #stop_server ⇒ Object
Constructor Details
#initialize(garden, stdout) ⇒ Main
Returns a new instance of Main.
9 10 11 12 |
# File 'lib/vita/main.rb', line 9 def initialize(garden, stdout) @garden = garden @stdout = stdout end |
Instance Attribute Details
#garden ⇒ Object (readonly)
Returns the value of attribute garden.
7 8 9 |
# File 'lib/vita/main.rb', line 7 def garden @garden end |
Instance Method Details
#call(*args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vita/main.rb', line 14 def call(*args) if garden.empty? puts "Your garden is empty. Create a text file in this directory first." return 1 end case args.first when "open", nil start_server open_browser 0 when "serve" start_server 0 when "publish" publish 0 else puts "Usage: vita [open|serve|publish]" 1 end end |
#join ⇒ Object
37 38 39 |
# File 'lib/vita/main.rb', line 37 def join @server_thread&.join end |
#stop_server ⇒ Object
41 42 43 |
# File 'lib/vita/main.rb', line 41 def stop_server @server_thread&.kill end |