Module: Crayon::MethodParser

Included in:
Crayon
Defined in:
lib/crayon/method_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse_backgroundObject



10
11
12
13
14
15
# File 'lib/crayon/method_parser.rb', line 10

def parse_background
  on_index = @method_name_components.index("on")
  return nil unless on_index
  background = @method_name_components.delete_at(on_index + 1)
  background if COLORS.include?(background)
end

#parse_foregroundObject



17
18
19
# File 'lib/crayon/method_parser.rb', line 17

def parse_foreground
  @method_name_components.find {|color| COLORS.include?(color) }
end

#parse_formattingObject



21
22
23
# File 'lib/crayon/method_parser.rb', line 21

def parse_formatting
  @method_name_components.select {|format| FORMATS.include?(format) }
end

#parse_method_nameObject



3
4
5
6
7
8
# File 'lib/crayon/method_parser.rb', line 3

def parse_method_name
  @method_name_components = @method_name.to_s.downcase.split("_")
  @background = parse_background
  @foreground = parse_foreground
  @formatting = parse_formatting
end