Class: Luca::ComponentDefinition::Line
- Inherits:
-
Object
- Object
- Luca::ComponentDefinition::Line
- Defined in:
- lib/luca/component_definition.rb
Instance Attribute Summary collapse
-
#found_in ⇒ Object
Returns the value of attribute found_in.
-
#line ⇒ Object
Returns the value of attribute line.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
Instance Method Summary collapse
- #body? ⇒ Boolean
- #comment? ⇒ Boolean
- #component ⇒ Object
- #component_definition? ⇒ Boolean
- #component_extension?(proxy) ⇒ Boolean
- #defines ⇒ Object
- #defines_method? ⇒ Boolean
- #defines_property? ⇒ Boolean
- #defines_property_or_method? ⇒ Boolean
- #details ⇒ Object
- #indentation_level ⇒ Object
-
#initialize(line, line_number) ⇒ Line
constructor
A new instance of Line.
- #match(pattern) ⇒ Object
- #split(delimiter) ⇒ Object
- #strip ⇒ Object
Constructor Details
#initialize(line, line_number) ⇒ Line
Returns a new instance of Line.
281 282 283 284 |
# File 'lib/luca/component_definition.rb', line 281 def initialize(line,line_number) @line = line @line_number = line_number end |
Instance Attribute Details
#found_in ⇒ Object
Returns the value of attribute found_in.
279 280 281 |
# File 'lib/luca/component_definition.rb', line 279 def found_in @found_in end |
#line ⇒ Object
Returns the value of attribute line.
279 280 281 |
# File 'lib/luca/component_definition.rb', line 279 def line @line end |
#line_number ⇒ Object
Returns the value of attribute line_number.
279 280 281 |
# File 'lib/luca/component_definition.rb', line 279 def line_number @line_number end |
Instance Method Details
#body? ⇒ Boolean
328 329 330 |
# File 'lib/luca/component_definition.rb', line 328 def body? indentation_level == 1 && line.match(/^\s+/) end |
#comment? ⇒ Boolean
320 321 322 |
# File 'lib/luca/component_definition.rb', line 320 def comment? line.match(/^(\s*)\#/) or line == "#\n" end |
#component ⇒ Object
332 333 334 |
# File 'lib/luca/component_definition.rb', line 332 def component found_in end |
#component_definition? ⇒ Boolean
336 337 338 |
# File 'lib/luca/component_definition.rb', line 336 def component_definition? line.match(/[A-Z].+\.register/) end |
#component_extension?(proxy) ⇒ Boolean
340 341 342 |
# File 'lib/luca/component_definition.rb', line 340 def component_extension?(proxy) line.include?("#{ proxy }.extends") end |
#defines ⇒ Object
348 349 350 351 352 |
# File 'lib/luca/component_definition.rb', line 348 def defines if defines_property_or_method? line.split(':').first.strip end end |
#defines_method? ⇒ Boolean
316 317 318 |
# File 'lib/luca/component_definition.rb', line 316 def defines_method? !comment? && indentation_level == 1 && line.match(/\s*\w+\:\s*\(.*\)/) end |
#defines_property? ⇒ Boolean
324 325 326 |
# File 'lib/luca/component_definition.rb', line 324 def defines_property? !comment? && !defines_method? && indentation_level == 1 && line.match(/\s*\w+\:.*\w*/) end |
#defines_property_or_method? ⇒ Boolean
344 345 346 |
# File 'lib/luca/component_definition.rb', line 344 def defines_property_or_method? defines_method? || defines_property? end |
#details ⇒ Object
298 299 300 301 302 303 304 |
# File 'lib/luca/component_definition.rb', line 298 def details { type: type, line_number: line_number, indentation_level: indentation_level } end |
#indentation_level ⇒ Object
306 307 308 309 310 311 312 313 314 |
# File 'lib/luca/component_definition.rb', line 306 def indentation_level space_count = if match = line.match(/\A */)[0] and match.length > 0 match.length else 0 end space_count / 2 end |
#match(pattern) ⇒ Object
286 287 288 |
# File 'lib/luca/component_definition.rb', line 286 def match pattern line.match(pattern) end |
#split(delimiter) ⇒ Object
290 291 292 |
# File 'lib/luca/component_definition.rb', line 290 def split delimiter line.split(delimiter) end |
#strip ⇒ Object
294 295 296 |
# File 'lib/luca/component_definition.rb', line 294 def strip line.strip end |