Class: Lightning::Method
- Inherits:
-
Object
- Object
- Lightning::Method
- Defined in:
- lib/lightning/plugin.rb
Constant Summary collapse
- TYPE =
{rpc: 0, hook: 1}
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#long_desc ⇒ Object
readonly
Returns the value of attribute long_desc.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #hook? ⇒ Boolean
-
#initialize(name, usage = nil, desc = nil, type: TYPE[:rpc], long_desc: nil) ⇒ Method
constructor
A new instance of Method.
- #rpc? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(name, usage = nil, desc = nil, type: TYPE[:rpc], long_desc: nil) ⇒ Method
Returns a new instance of Method.
16 17 18 19 20 21 22 |
# File 'lib/lightning/plugin.rb', line 16 def initialize(name, usage = nil, desc = nil, type: TYPE[:rpc], long_desc: nil) @name = name @type = type @usage = usage @desc = desc @long_desc = long_desc end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
13 14 15 |
# File 'lib/lightning/plugin.rb', line 13 def desc @desc end |
#long_desc ⇒ Object (readonly)
Returns the value of attribute long_desc.
14 15 16 |
# File 'lib/lightning/plugin.rb', line 14 def long_desc @long_desc end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/lightning/plugin.rb', line 10 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/lightning/plugin.rb', line 11 def type @type end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
12 13 14 |
# File 'lib/lightning/plugin.rb', line 12 def usage @usage end |
Instance Method Details
#hook? ⇒ Boolean
28 29 30 |
# File 'lib/lightning/plugin.rb', line 28 def hook? type == TYPE[:hook] end |
#rpc? ⇒ Boolean
24 25 26 |
# File 'lib/lightning/plugin.rb', line 24 def rpc? type == TYPE[:rpc] && ![:init, :getmanifest].include?(name) end |
#to_h ⇒ Object
32 33 34 35 36 |
# File 'lib/lightning/plugin.rb', line 32 def to_h result = {name: name.to_s, usage: usage, description: desc} result[:long_description] = long_desc if long_desc result end |