class CSP::Directive

Constants

DIRECTIVE_VALUES
ParseError

Attributes

name[R]
value[R]

Public Class Methods

new(value_str) click to toggle source
# File lib/directive.rb, line 39
def initialize(value_str)
  @value_str = value_str
  @match = value_str.match(/\A#{CSP::Grammar::SERIALIZED_DIRECTIVE}\z/o)

  raise ParseError, @value_str if @match.nil?

  @name = @match["name"]
  value_class = DIRECTIVE_VALUES[@name] || CSP::DirectiveValue::Default
  @value = value_class.new(@match["value"])
end

Public Instance Methods

to_s() click to toggle source
# File lib/directive.rb, line 52
def to_s
  @value_str
end