Class: MetricFu::Saikuro::ParsingElement
- Inherits:
-
Object
- Object
- MetricFu::Saikuro::ParsingElement
- Defined in:
- lib/generators/saikuro.rb
Constant Summary collapse
- TYPE_REGEX =
/Type:(.*) Name/
- NAME_REGEX =
/Name:(.*) Complexity/
- COMPLEXITY_REGEX =
/Complexity:(.*) Lines/
- LINES_REGEX =
/Lines:(.*)/
Instance Attribute Summary collapse
-
#complexity ⇒ Object
readonly
Returns the value of attribute complexity.
-
#defs ⇒ Object
readonly
Returns the value of attribute defs.
-
#element_type ⇒ Object
readonly
Returns the value of attribute element_type.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #<<(line) ⇒ Object
-
#initialize(line) ⇒ ParsingElement
constructor
A new instance of ParsingElement.
- #to_h ⇒ Object
Constructor Details
#initialize(line) ⇒ ParsingElement
Returns a new instance of ParsingElement.
198 199 200 201 202 203 204 205 |
# File 'lib/generators/saikuro.rb', line 198 def initialize(line) @line = line @element_type = line.match(TYPE_REGEX)[1].strip @name = line.match(NAME_REGEX)[1].strip @complexity = line.match(COMPLEXITY_REGEX)[1].strip @lines = line.match(LINES_REGEX)[1].strip @defs = [] end |
Instance Attribute Details
#complexity ⇒ Object (readonly)
Returns the value of attribute complexity.
195 196 197 |
# File 'lib/generators/saikuro.rb', line 195 def complexity @complexity end |
#defs ⇒ Object (readonly)
Returns the value of attribute defs.
195 196 197 |
# File 'lib/generators/saikuro.rb', line 195 def defs @defs end |
#element_type ⇒ Object (readonly)
Returns the value of attribute element_type.
195 196 197 |
# File 'lib/generators/saikuro.rb', line 195 def element_type @element_type end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
195 196 197 |
# File 'lib/generators/saikuro.rb', line 195 def lines @lines end |
#name ⇒ Object
Returns the value of attribute name.
196 197 198 |
# File 'lib/generators/saikuro.rb', line 196 def name @name end |
Instance Method Details
#<<(line) ⇒ Object
207 208 209 |
# File 'lib/generators/saikuro.rb', line 207 def <<(line) @defs << Saikuro::ParsingElement.new(line) end |
#to_h ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/generators/saikuro.rb', line 211 def to_h base = {:name => @name, :complexity => @complexity.to_i, :lines => @lines.to_i} unless @defs.empty? defs = @defs.map do |my_def| my_def = my_def.to_h my_def.delete(:defs) my_def end base[:defs] = defs end return base end |