class SoftLayer::ObjectMaskToken
This class is an implementation detail of the Object Mask Parser It represents a single semantic token as parsed out of an Object Mask String
The class also generates error messages that the parser can use when it encounters an unexpected token
Constants
- KnownTokenTypes
Attributes
type[R]
value[R]
Public Class Methods
error_for_unexpected_token(token)
click to toggle source
# File lib/softlayer/ObjectMaskToken.rb, line 65 def self.error_for_unexpected_token(token) case token.type when :invalid_token "Unrecognized token '#{token.value}'" when :eos "Unexpected end of string" when :identifier "Unexpected identifier '#{token.value}'" when :property_set_start "Unexpected '['" when :property_set_separator "Unexpected ','" when :property_set_end "Unexpected ']'" when :property_type_start "Unexpected '('" when :property_type_end "Unexpected ')'" when :property_child_separator "Unexpected '.'" else "Unexpected value (invalid token type)" end end
new(token_type, token_value = nil)
click to toggle source
# File lib/softlayer/ObjectMaskToken.rb, line 32 def initialize(token_type, token_value = nil) @type = token_type @value = token_value end
Public Instance Methods
end_of_string?()
click to toggle source
# File lib/softlayer/ObjectMaskToken.rb, line 49 def end_of_string? return @type == :eos end
eql?(other_token)
click to toggle source
# File lib/softlayer/ObjectMaskToken.rb, line 41 def eql?(other_token) @type.eql?(other_token.type) && @value.eql?(other_token.value) end
inspect()
click to toggle source
# File lib/softlayer/ObjectMaskToken.rb, line 37 def inspect "<#{@type.inspect}, #{@value.inspect}>" end
invalid?()
click to toggle source
# File lib/softlayer/ObjectMaskToken.rb, line 45 def invalid? return @type = :invalid_token end
mask_root_marker?()
click to toggle source
# File lib/softlayer/ObjectMaskToken.rb, line 53 def mask_root_marker? return @type == :identifier && (@value == "mask" || @value == "filterMask") end
valid_property_name?()
click to toggle source
# File lib/softlayer/ObjectMaskToken.rb, line 57 def valid_property_name? return @type == :identifier && @value.match(/\A[a-z][a-z0-9]*\z/i) end
valid_property_type?()
click to toggle source
# File lib/softlayer/ObjectMaskToken.rb, line 61 def valid_property_type? return @type == :identifier && @value.match(/\A[a-z][a-z0-9]*(_[a-z][a-z0-9]*)*\z/i) end