Class: IMW::Resource
- Inherits:
-
Object
- Object
- IMW::Resource
- Includes:
- Utils::DynamicallyExtendable, Utils::HasURI
- Defined in:
- lib/imw.rb,
lib/imw/resource.rb
Instance Attribute Summary collapse
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#resource_options ⇒ Object
Returns the value of attribute resource_options.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(uri, options = {}) ⇒ Resource
constructor
A new instance of Resource.
- #reopen ⇒ Object
- #should_exist!(message = nil) ⇒ Object
Constructor Details
#initialize(uri, options = {}) ⇒ Resource
Returns a new instance of Resource.
28 29 30 31 |
# File 'lib/imw.rb', line 28 def initialize(uri, mode='r') raise FileModeError.new("'#{mode}' is not a valid access mode") unless valid_modes.include? mode @uri = Uri.new(uri) end |
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
6 7 8 |
# File 'lib/imw/resource.rb', line 6 def mode @mode end |
#resource_options ⇒ Object
Returns the value of attribute resource_options.
6 7 8 |
# File 'lib/imw/resource.rb', line 6 def @resource_options end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
26 27 28 |
# File 'lib/imw.rb', line 26 def uri @uri end |
Class Method Details
.exists?(resource) ⇒ Boolean
42 43 44 |
# File 'lib/imw.rb', line 42 def self.exists? resource true end |
Instance Method Details
#close ⇒ Object
33 34 |
# File 'lib/imw/resource.rb', line 33 def close end |
#should_exist!(message = nil) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/imw/resource.rb', line 26 def should_exist!(=nil) raise IMW::Error.new([, "No path defined for #{self.inspect} extended by #{modules.join(' ')}"].compact.join(', ')) unless respond_to?(:path) raise IMW::Error.new([, "No exist? method defined for #{self.inspect} extended by #{modules.join(' ')}"].compact.join(', ')) unless respond_to?(:exist?) raise IMW::PathError.new([, "#{path} does not exist"].compact.join(', ')) unless exist? self end |