Class: Sh::Actions
Constant Summary collapse
- @@actions =
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#user_data ⇒ Object
readonly
Returns the value of attribute user_data.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #execute(*args) ⇒ Object
-
#initialize(name, *tags, &block) ⇒ Actions
constructor
A new instance of Actions.
Constructor Details
#initialize(name, *tags, &block) ⇒ Actions
Returns a new instance of Actions.
6 7 8 9 10 11 12 |
# File 'lib/sh_actions.rb', line 6 def initialize name, *, &block @@actions << self @name = name @tags = @block = block @user_data = {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/sh_actions.rb', line 4 def name @name end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
4 5 6 |
# File 'lib/sh_actions.rb', line 4 def @tags end |
#user_data ⇒ Object (readonly)
Returns the value of attribute user_data.
4 5 6 |
# File 'lib/sh_actions.rb', line 4 def user_data @user_data end |
Class Method Details
.get(*tags) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sh_actions.rb', line 26 def self.get * matches = [] @@actions.each do |action| subset = true .each do |tag| subset = false unless action..include? tag end matches << action if subset end return matches end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 |
# File 'lib/sh_actions.rb', line 18 def [](key) return @user_data[key] end |
#[]=(key, value) ⇒ Object
14 15 16 |
# File 'lib/sh_actions.rb', line 14 def []=(key, value) @user_data[key] = value end |
#execute(*args) ⇒ Object
22 23 24 |
# File 'lib/sh_actions.rb', line 22 def execute *args @block.call *args end |