Class: MiniCSS::CSS::AST::SimpleBlock
- Inherits:
-
Object
- Object
- MiniCSS::CSS::AST::SimpleBlock
- Defined in:
- lib/minicss/css/ast/simple_block.rb
Constant Summary collapse
- RIGHT_TOKENS =
{ left_parenthesis: ")", left_curly: "}", left_square_bracket: "]" }.freeze
- LEFT_TOKENS =
{ left_parenthesis: "(", left_curly: "{", left_square_bracket: "[" }.freeze
Instance Attribute Summary collapse
-
#associated_token ⇒ Object
Returns the value of attribute associated_token.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #convert_value(val) ⇒ Object
-
#initialize(associated_token:) ⇒ SimpleBlock
constructor
A new instance of SimpleBlock.
- #kind ⇒ Object
- #left_token ⇒ Object
- #literal ⇒ Object
- #right_token ⇒ Object
Constructor Details
#initialize(associated_token:) ⇒ SimpleBlock
Returns a new instance of SimpleBlock.
21 22 23 24 |
# File 'lib/minicss/css/ast/simple_block.rb', line 21 def initialize(associated_token:) @associated_token = associated_token @value = [] end |
Instance Attribute Details
#associated_token ⇒ Object
Returns the value of attribute associated_token.
19 20 21 |
# File 'lib/minicss/css/ast/simple_block.rb', line 19 def associated_token @associated_token end |
#value ⇒ Object
Returns the value of attribute value.
19 20 21 |
# File 'lib/minicss/css/ast/simple_block.rb', line 19 def value @value end |
Instance Method Details
#convert_value(val) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/minicss/css/ast/simple_block.rb', line 35 def convert_value(val) case val.kind when :ident, :delim val.literal when :string q = val.opts[:quoting] [q, val.literal, q].join else raise "Unexpected type in value: #{val.kind}" end end |
#kind ⇒ Object
26 |
# File 'lib/minicss/css/ast/simple_block.rb', line 26 def kind = :simple_block |
#left_token ⇒ Object
29 |
# File 'lib/minicss/css/ast/simple_block.rb', line 29 def left_token = LEFT_TOKENS[associated_token] |
#literal ⇒ Object
31 32 33 |
# File 'lib/minicss/css/ast/simple_block.rb', line 31 def literal [left_token, @value.map { convert_value(it) }.join, right_token].join end |
#right_token ⇒ Object
28 |
# File 'lib/minicss/css/ast/simple_block.rb', line 28 def right_token = RIGHT_TOKENS[associated_token] |