Class: Luca::ComponentDefinition::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/luca/component_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_inObject

Returns the value of attribute found_in.



279
280
281
# File 'lib/luca/component_definition.rb', line 279

def found_in
  @found_in
end

#lineObject

Returns the value of attribute line.



279
280
281
# File 'lib/luca/component_definition.rb', line 279

def line
  @line
end

#line_numberObject

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

Returns:

  • (Boolean)


328
329
330
# File 'lib/luca/component_definition.rb', line 328

def body?
  indentation_level == 1 && line.match(/^\s+/)
end

#comment?Boolean

Returns:

  • (Boolean)


320
321
322
# File 'lib/luca/component_definition.rb', line 320

def comment?
  line.match(/^(\s*)\#/) or line == "#\n"
end

#componentObject



332
333
334
# File 'lib/luca/component_definition.rb', line 332

def component
  found_in
end

#component_definition?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


340
341
342
# File 'lib/luca/component_definition.rb', line 340

def component_extension?(proxy)
  line.include?("#{ proxy }.extends") 
end

#definesObject



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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


344
345
346
# File 'lib/luca/component_definition.rb', line 344

def defines_property_or_method?
  defines_method? || defines_property?
end

#detailsObject



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_levelObject



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

#stripObject



294
295
296
# File 'lib/luca/component_definition.rb', line 294

def strip
  line.strip 
end