Class: YAMLCommand::Command
- Inherits:
-
Executable::Command
- Object
- Executable::Command
- YAMLCommand::Command
- Defined in:
- lib/yaml_command/base.rb
Overview
Abstract base command that all others use.
Direct Known Subclasses
Command::GetCommand, Command::SetCommand, EditCommand, SlurpCommand, SortCommand, SplatCommand, ViewCommand
Defined Under Namespace
Classes: EditCommand, GetCommand, SetCommand, SlurpCommand, SortCommand, SplatCommand, ViewCommand
Instance Attribute Summary collapse
-
#file ⇒ Object
YAML file to use as data source.
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
YAML Command.
-
#debug=(boolean) ⇒ Object
Debug mode.
-
#debug? ⇒ Boolean
Debug mode.
-
#h! ⇒ Object
Show minimal help message.
-
#help! ⇒ Object
Show detailed help message.
-
#inspect=(boolean) ⇒ Object
Output using Ruby’s #inspect method.
-
#inspect? ⇒ Boolean
Output using Ruby’s #inspect method.
-
#json=(boolean) ⇒ Object
Output using #to_json.
-
#json? ⇒ Boolean
Output using #to_json.
-
#mute=(boolean) ⇒ Object
Surpress all output.
-
#mute? ⇒ Boolean
Surpress all output.
-
#yaml=(boolean) ⇒ Object
Output using #to_yaml.
-
#yaml? ⇒ Boolean
Output using #to_yaml.
Instance Attribute Details
#file ⇒ Object
YAML file to use as data source. This can be used as an alternative to ‘$stdin`.
28 29 30 |
# File 'lib/yaml_command/base.rb', line 28 def file @file end |
Class Method Details
.command_name ⇒ Object
8 9 10 |
# File 'lib/yaml_command/base.rb', line 8 def self.command_name 'yaml' end |
Instance Method Details
#call ⇒ Object
YAML Command
90 91 92 93 94 95 96 |
# File 'lib/yaml_command/base.rb', line 90 def call if file output(data) else puts cli end end |
#debug=(boolean) ⇒ Object
Debug mode.
13 14 15 |
# File 'lib/yaml_command/base.rb', line 13 def debug=(boolean) $DEBUG = boolean ? true : false end |
#debug? ⇒ Boolean
Debug mode.
18 19 20 |
# File 'lib/yaml_command/base.rb', line 18 def debug? $DEBUG end |
#h! ⇒ Object
Show minimal help message.
84 85 86 87 |
# File 'lib/yaml_command/base.rb', line 84 def h! puts cli exit end |
#help! ⇒ Object
Show detailed help message.
78 79 80 81 |
# File 'lib/yaml_command/base.rb', line 78 def help! cli.show_help exit end |
#inspect=(boolean) ⇒ Object
Output using Ruby’s #inspect method.
32 33 34 |
# File 'lib/yaml_command/base.rb', line 32 def inspect=(boolean) @format = :inspect if boolean end |
#inspect? ⇒ Boolean
Output using Ruby’s #inspect method.
37 38 39 |
# File 'lib/yaml_command/base.rb', line 37 def inspect? @format == :inspect end |
#json=(boolean) ⇒ Object
Output using #to_json.
54 55 56 |
# File 'lib/yaml_command/base.rb', line 54 def json=(boolean) @format = :json if boolean end |
#json? ⇒ Boolean
Output using #to_json.
59 60 61 |
# File 'lib/yaml_command/base.rb', line 59 def json? @format == :json end |
#mute=(boolean) ⇒ Object
Surpress all output.
71 72 73 |
# File 'lib/yaml_command/base.rb', line 71 def mute=(boolean) @format = :mute if boolean end |
#mute? ⇒ Boolean
Surpress all output.
66 67 68 |
# File 'lib/yaml_command/base.rb', line 66 def mute? @format == :mute end |
#yaml=(boolean) ⇒ Object
Output using #to_yaml.
42 43 44 |
# File 'lib/yaml_command/base.rb', line 42 def yaml=(boolean) @format = :yaml if boolean end |
#yaml? ⇒ Boolean
Output using #to_yaml.
47 48 49 |
# File 'lib/yaml_command/base.rb', line 47 def yaml? @format == :yaml end |