Class: Lightning::Method

Inherits:
Object
  • Object
show all
Defined in:
lib/lightning/plugin.rb

Constant Summary collapse

TYPE =
{rpc: 0, hook: 1}

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descObject (readonly)

Returns the value of attribute desc.



13
14
15
# File 'lib/lightning/plugin.rb', line 13

def desc
  @desc
end

#long_descObject (readonly)

Returns the value of attribute long_desc.



14
15
16
# File 'lib/lightning/plugin.rb', line 14

def long_desc
  @long_desc
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/lightning/plugin.rb', line 10

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



11
12
13
# File 'lib/lightning/plugin.rb', line 11

def type
  @type
end

#usageObject (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

Returns:

  • (Boolean)


28
29
30
# File 'lib/lightning/plugin.rb', line 28

def hook?
  type == TYPE[:hook]
end

#rpc?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/lightning/plugin.rb', line 24

def rpc?
  type == TYPE[:rpc] && ![:init, :getmanifest].include?(name)
end

#to_hObject



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