Method: Languages::Ruby::AttributeRuby#get_attribute

Defined in:
lib/kuniri/language/ruby/attribute_ruby.rb

#get_attribute(pLine) ⇒ Object

Get ruby attribute.

Parameters:

  • pLine

    Verify if line has a ruby attribute.

Returns:

  • Return AttributeData or nil.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/kuniri/language/ruby/attribute_ruby.rb', line 21

def get_attribute(pLine)
  result = detect_attribute(pLine)
  return nil unless result

  listOfAttributes = []

  # Has comma? Split string by comma
  result = remove_unnecessary_information(result)

  # Separated by comma, equal or the common case
  if result.scan(/,/).count >= 1
    listOfAttributes = handle_multiple_declaration_with_comma(result)
  elsif result.scan(/=/).count > 1
    listOfAttributes = handle_multiple_declaration_with_equal(result)
  else
    listOfAttributes = handle_line_declaration(result)
  end

  return listOfAttributes
end