Class: Deckr::Resource
- Inherits:
-
Object
- Object
- Deckr::Resource
- Defined in:
- lib/deckr/resource.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #content ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(parent, name) ⇒ Resource
constructor
A new instance of Resource.
- #path ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(parent, name) ⇒ Resource
Returns a new instance of Resource.
5 6 7 |
# File 'lib/deckr/resource.rb', line 5 def initialize(parent, name) @parent, @name = parent, name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/deckr/resource.rb', line 3 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
3 4 5 |
# File 'lib/deckr/resource.rb', line 3 def parent @parent end |
Instance Method Details
#==(other) ⇒ Object
31 32 33 34 35 |
# File 'lib/deckr/resource.rb', line 31 def ==(other) other.respond_to?(:parent) && parent == other.parent && other.respond_to?(:url) && url == other.url && other.respond_to?(:path) && path == other.path end |
#content ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/deckr/resource.rb', line 21 def content if not exist? "" elsif RUBY_VERSION >= "1.9" IO.read path, :mode => "rb" else IO.read path end end |
#exist? ⇒ Boolean
17 18 19 |
# File 'lib/deckr/resource.rb', line 17 def exist? File.file?(path) end |
#path ⇒ Object
13 14 15 |
# File 'lib/deckr/resource.rb', line 13 def path File.join(parent.path, name) end |
#url ⇒ Object
9 10 11 |
# File 'lib/deckr/resource.rb', line 9 def url File.join(parent.url, name) end |