Class: MethodChainingLimit
- Inherits:
-
Object
- Object
- MethodChainingLimit
- Defined in:
- lib/rules/method_chaining_limit.rb
Instance Method Summary collapse
-
#initialize(max) ⇒ MethodChainingLimit
constructor
A new instance of MethodChainingLimit.
- #message ⇒ Object
- #valid?(code) ⇒ Boolean
Constructor Details
#initialize(max) ⇒ MethodChainingLimit
Returns a new instance of MethodChainingLimit.
2 3 4 |
# File 'lib/rules/method_chaining_limit.rb', line 2 def initialize(max) @max = max end |
Instance Method Details
#message ⇒ Object
12 13 14 |
# File 'lib/rules/method_chaining_limit.rb', line 12 def "more than one dot per line" end |
#valid?(code) ⇒ Boolean
6 7 8 9 10 |
# File 'lib/rules/method_chaining_limit.rb', line 6 def valid?(code) code.gsub(/\d+\.\d+/,'').split("\n").all? do |line| line.count('.') <= @max end end |