Class: Himari::TokenString::Format

Inherits:
Struct
  • Object
show all
Defined in:
lib/himari/token_string.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#handleObject

Returns the value of attribute handle

Returns:

  • (Object)

    the current value of handle



75
76
77
# File 'lib/himari/token_string.rb', line 75

def handle
  @handle
end

#headerObject

Returns the value of attribute header

Returns:

  • (Object)

    the current value of header



75
76
77
# File 'lib/himari/token_string.rb', line 75

def header
  @header
end

#secretObject

Returns the value of attribute secret

Returns:

  • (Object)

    the current value of secret



75
76
77
# File 'lib/himari/token_string.rb', line 75

def secret
  @secret
end

Class Method Details

.parse(header, str) ⇒ Object

Raises:



76
77
78
79
80
81
# File 'lib/himari/token_string.rb', line 76

def self.parse(header, str)
  parts = str.split('.')
  raise InvalidFormat unless parts.size == 3
  raise InvalidFormat unless parts[0] == header
  new(header: header, handle: parts[1], secret: parts[2])
end

Instance Method Details

#to_sObject



83
84
85
# File 'lib/himari/token_string.rb', line 83

def to_s
  "#{header}.#{handle}.#{secret}"
end