Class: Docks::Parsers::CSS
Instance Attribute Summary
Attributes inherited from Base
#comment_line_pattern, #comment_pattern, #pattern_block_extractor, #symbol_block_extractor
Instance Method Summary collapse
-
#initialize ⇒ CSS
constructor
A new instance of CSS.
- #symbol_details_from_first_line(first_code_line) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ CSS
Returns a new instance of CSS.
7 8 9 10 11 |
# File 'lib/docks/parsers/css_parser.rb', line 7 def initialize @comment_pattern = /(?:\/\*|\*\/?)/ @first_non_code_line_pattern = /[\.#\w\[@]/ setup_regexes end |
Instance Method Details
#symbol_details_from_first_line(first_code_line) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/docks/parsers/css_parser.rb', line 13 def symbol_details_from_first_line(first_code_line) first_code_line.strip! type = case first_code_line when /(\.|\-\-)?(?:is|js)\-/ then Docks::Types::Symbol::STATE when /\-\-(?:[a-zA-Z][\-_]?)*/ then Docks::Types::Symbol::VARIANT else Docks::Types::Symbol::COMPONENT end name = first_code_line.match(/^\s*[\.#]([^\s\:\.#]*)/).captures.first { name: name, symbol_type: type } end |