Class: SlackBot::Args
- Inherits:
-
Object
- Object
- SlackBot::Args
- Defined in:
- lib/slack_bot/args.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #except(*keys) ⇒ Object
-
#initialize(builder: ArgsBuilder, parser: ArgsParser) ⇒ Args
constructor
A new instance of Args.
- #merge(**other_args) ⇒ Object
- #raw_args=(raw_args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(builder: ArgsBuilder, parser: ArgsParser) ⇒ Args
Returns a new instance of Args.
28 29 30 31 32 |
# File 'lib/slack_bot/args.rb', line 28 def initialize(builder: ArgsBuilder, parser: ArgsParser) @args = {} @builder = builder @parser = parser end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
27 28 29 |
# File 'lib/slack_bot/args.rb', line 27 def args @args end |
Instance Method Details
#[](key) ⇒ Object
34 35 36 |
# File 'lib/slack_bot/args.rb', line 34 def [](key) args[key] end |
#[]=(key, value) ⇒ Object
38 39 40 |
# File 'lib/slack_bot/args.rb', line 38 def []=(key, value) args[key] = value end |
#except(*keys) ⇒ Object
57 58 59 60 61 |
# File 'lib/slack_bot/args.rb', line 57 def except(*keys) self.class.new.tap do |new_args| new_args.args = args.except(*keys) end end |
#merge(**other_args) ⇒ Object
51 52 53 54 55 |
# File 'lib/slack_bot/args.rb', line 51 def merge(**other_args) self.class.new.tap do |new_args| new_args.args = args.merge(other_args) end end |
#raw_args=(raw_args) ⇒ Object
42 43 44 45 |
# File 'lib/slack_bot/args.rb', line 42 def raw_args=(raw_args) @raw_args = raw_args self.args = @parser.new(raw_args).call&.with_indifferent_access || {} end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/slack_bot/args.rb', line 47 def to_s @builder.new(args).call end |