Class: MetricFu::Flog::ScannedMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/flog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, score, operators = []) ⇒ ScannedMethod

Returns a new instance of ScannedMethod.



125
126
127
128
129
130
131
132
133
# File 'lib/generators/flog.rb', line 125

def initialize(name, score, operators = [])
  if name.match(/\.rb:\d*/)
    @line = name.match(/\.rb:\d*/).to_s.sub('.rb:','')
    name = name.match(/\S*/)
  end
  @name = name
  @score = score.to_f
  @operators = operators
end

Instance Attribute Details

#lineObject

Returns the value of attribute line.



123
124
125
# File 'lib/generators/flog.rb', line 123

def line
  @line
end

#nameObject

Returns the value of attribute name.



123
124
125
# File 'lib/generators/flog.rb', line 123

def name
  @name
end

#operatorsObject

Returns the value of attribute operators.



123
124
125
# File 'lib/generators/flog.rb', line 123

def operators
  @operators
end

#scoreObject

Returns the value of attribute score.



123
124
125
# File 'lib/generators/flog.rb', line 123

def score
  @score
end

Instance Method Details

#to_hObject



135
136
137
138
139
140
# File 'lib/generators/flog.rb', line 135

def to_h
  {:name => @name,
    :score => @score,
    :operators => @operators.map {|o| o.to_h},
    :line => @line}
end