Class: Weary::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/weary/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Resource

Returns a new instance of Resource.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/weary/resource.rb', line 5

def initialize(name,options={})
  @domain = options[:domain]
  self.name = name
  self.via = options[:via]
  self.with = options[:with]
  self.requires = options[:requires]
  self.format = options[:format]
  self.url = options[:url]
  @authenticates = (options[:authenticates] != false)
  @follows = (options[:no_follow] == false)
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



3
4
5
# File 'lib/weary/resource.rb', line 3

def format
  @format
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/weary/resource.rb', line 3

def name
  @name
end

#requiresObject

Returns the value of attribute requires.



3
4
5
# File 'lib/weary/resource.rb', line 3

def requires
  @requires
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/weary/resource.rb', line 3

def url
  @url
end

#viaObject

Returns the value of attribute via.



3
4
5
# File 'lib/weary/resource.rb', line 3

def via
  @via
end

#withObject

Returns the value of attribute with.



3
4
5
# File 'lib/weary/resource.rb', line 3

def with
  @with
end

Instance Method Details

#authenticates?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/weary/resource.rb', line 55

def authenticates?
  @authenticates
end

#follows_redirects?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/weary/resource.rb', line 59

def follows_redirects?
  @follows
end

#to_hashObject



63
64
65
66
67
68
69
70
71
# File 'lib/weary/resource.rb', line 63

def to_hash
  {@name.to_sym => {:via => @via,
                    :with => @with,
                    :requires => @requires,
                    :authenticates => authenticates?,
                    :format => @format,
                    :url => @url},
                    :no_follow => !follows_redirects?}
end