Class: DevSystem::MethodShell
- Inherits:
-
Shell
- Object
- Liza::Unit
- Liza::Controller
- Shell
- DevSystem::MethodShell
- Defined in:
- lib/dev_system/sub/shell/shells/method_shell.rb
Defined Under Namespace
Classes: NotFoundError
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(object, method_name) ⇒ MethodShell
constructor
A new instance of MethodShell.
- #line ⇒ Object
- #line_location ⇒ Object
- #method(sym = nil) ⇒ Object
- #signature_has_single_parameter_named?(name) ⇒ Boolean
Methods inherited from Shell
cruby?, engine, jruby?, linux?, mac?, os, ruby_version, unix?, windows?
Methods inherited from Liza::Controller
color, inherited, on_connected
Methods inherited from Liza::Unit
const_missing, division, part, system, #system, test_class
Constructor Details
#initialize(object, method_name) ⇒ MethodShell
Returns a new instance of MethodShell.
15 16 17 18 19 20 21 22 23 |
# File 'lib/dev_system/sub/shell/shells/method_shell.rb', line 15 def initialize(object, method_name) super() @object = object @method_name = method_name @method = object.method method_name rescue NameError raise NotFoundError, "method not found: #{method_name.inspect}", caller end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
13 14 15 |
# File 'lib/dev_system/sub/shell/shells/method_shell.rb', line 13 def method_name @method_name end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
13 14 15 |
# File 'lib/dev_system/sub/shell/shells/method_shell.rb', line 13 def object @object end |
Class Method Details
.signature_has_single_parameter_named?(object, method_name, arg_name) ⇒ Boolean
6 7 8 9 |
# File 'lib/dev_system/sub/shell/shells/method_shell.rb', line 6 def self.signature_has_single_parameter_named?(object, method_name, arg_name) return false unless object.respond_to? method_name new(object, method_name).signature_has_single_parameter_named?(arg_name) end |
Instance Method Details
#line ⇒ Object
34 35 36 |
# File 'lib/dev_system/sub/shell/shells/method_shell.rb', line 34 def line @line ||= File.readlines(@method.source_location[0])[@method.source_location[1] - 1].strip end |
#line_location ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/dev_system/sub/shell/shells/method_shell.rb', line 38 def line_location @line_location ||= begin path = @method.source_location[0].gsub(App.root.to_s, "")[1..-1] line_number = @method.source_location[1] "#{path}:#{line_number}" end end |
#method(sym = nil) ⇒ Object
27 28 29 30 |
# File 'lib/dev_system/sub/shell/shells/method_shell.rb', line 27 def method(sym=nil) return super if sym @method end |
#signature_has_single_parameter_named?(name) ⇒ Boolean
48 49 50 |
# File 'lib/dev_system/sub/shell/shells/method_shell.rb', line 48 def signature_has_single_parameter_named?(name) @method.parameters == [[:req, name]] end |