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



110
111
112
# File 'lib/himari/token_string.rb', line 110

def handle
  @handle
end

#headerObject

Returns the value of attribute header

Returns:

  • (Object)

    the current value of header



110
111
112
# File 'lib/himari/token_string.rb', line 110

def header
  @header
end

#secretObject

Returns the value of attribute secret

Returns:

  • (Object)

    the current value of secret



110
111
112
# File 'lib/himari/token_string.rb', line 110

def secret
  @secret
end

Class Method Details

.parse(header, str) ⇒ Object

Raises:



111
112
113
114
115
116
117
# File 'lib/himari/token_string.rb', line 111

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



119
120
121
# File 'lib/himari/token_string.rb', line 119

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