Class: Pluct::Schema

Inherits:
Object
  • Object
show all
Includes:
Helpers::Request
Defined in:
lib/pluct/schema.rb

Constant Summary

Constants included from Helpers::Request

Helpers::Request::DEFAULT_HEADERS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Schema

Returns a new instance of Schema.



7
8
9
# File 'lib/pluct/schema.rb', line 7

def initialize(path)
  @path = path
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/pluct/schema.rb', line 5

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/pluct/schema.rb', line 5

def path
  @path
end

Class Method Details

.from_header(headers) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/pluct/schema.rb', line 23

def self.from_header(headers)
  return nil unless headers[:content_type]
              
  schema = headers[:content_type].match('.*profile=([^;]+);?')
  return nil unless schema      
  
  Schema.new(schema[1])
end

Instance Method Details



15
16
17
# File 'lib/pluct/schema.rb', line 15

def links
  self.data["links"]
end

#to_sObject



19
20
21
# File 'lib/pluct/schema.rb', line 19

def to_s
  @path  
end