Class: Clitopic::Topic::Base
- Inherits:
-
Object
- Object
- Clitopic::Topic::Base
- Defined in:
- lib/clitopic/topic/base.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Instance Attribute Summary collapse
-
#banner ⇒ Object
Returns the value of attribute banner.
-
#description(arg = nil) ⇒ Object
Returns the value of attribute description.
-
#hidden(arg = false) ⇒ Object
(also: #hidden?)
Returns the value of attribute hidden.
-
#name(arg = nil) ⇒ Object
Returns the value of attribute name.
-
#short_description ⇒ Object
Returns the value of attribute short_description.
Class Method Summary collapse
- .option(name, *args, &blk) ⇒ Object
- .options ⇒ Object
- .register(opts = {}, force = false) ⇒ Object
- .topic_options ⇒ Object
Instance Method Summary collapse
- #commands ⇒ Object
-
#initialize(opts = {}, force = false) ⇒ Base
constructor
A new instance of Base.
- #topic_options ⇒ Object
Constructor Details
#initialize(opts = {}, force = false) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/clitopic/topic/base.rb', line 10 def initialize(opts={}, force=false) opts = {hidden: false}.merge(opts) if !opts.has_key?(:name) raise ArgumentError.new("missing Topic name") end @description = opts[:description] @short_description = opts[:short_description] @name = opts[:name] @hidden = opts[:hidden] = opts[:banner] end |
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
62 63 64 |
# File 'lib/clitopic/topic/base.rb', line 62 def instance @instance end |
Instance Attribute Details
#banner ⇒ Object
Returns the value of attribute banner.
8 9 10 |
# File 'lib/clitopic/topic/base.rb', line 8 def end |
#description(arg = nil) ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/clitopic/topic/base.rb', line 8 def description @description end |
#hidden(arg = false) ⇒ Object Also known as:
Returns the value of attribute hidden.
8 9 10 |
# File 'lib/clitopic/topic/base.rb', line 8 def hidden @hidden end |
#name(arg = nil) ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/clitopic/topic/base.rb', line 8 def name @name end |
#short_description ⇒ Object
Returns the value of attribute short_description.
8 9 10 |
# File 'lib/clitopic/topic/base.rb', line 8 def short_description @short_description end |
Class Method Details
.option(name, *args, &blk) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/clitopic/topic/base.rb', line 63 def option(name, *args, &blk) opt = Clitopic::Utils.parse_option(name, *args, &blk) if !opt[:default].nil? [name] = opt[:default] end << opt end |
.options ⇒ Object
58 59 60 |
# File 'lib/clitopic/topic/base.rb', line 58 def ||= {} end |
.register(opts = {}, force = false) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/clitopic/topic/base.rb', line 75 def register(opts={}, force=false) topic = self.new(opts, force) if Topics.topics.has_key?(topic.name) && !force raise TopicAlreadyExists.new ("Topic: #{topic.name} already exists: #{Topics[topic.name].class.name}") else if self.class != Clitopic::Topic::Base @instance = topic end Topics[topic.name] = topic end end |
.topic_options ⇒ Object
71 72 73 |
# File 'lib/clitopic/topic/base.rb', line 71 def ||= [] end |
Instance Method Details
#commands ⇒ Object
22 23 24 |
# File 'lib/clitopic/topic/base.rb', line 22 def commands @commands ||= {} end |
#topic_options ⇒ Object
48 49 50 |
# File 'lib/clitopic/topic/base.rb', line 48 def self.class. end |