Class: Peregrin::Resource
- Inherits:
-
Object
- Object
- Peregrin::Resource
- Defined in:
- lib/peregrin/resource.rb
Overview
Any file that is a part of the book but not one of its linear sections (ie, Components) is a Resource.
Resources can potentially be quite large, so as far as possible we don’t store their contents in memory.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
- #media_type ⇒ Object
-
#src ⇒ Object
Returns the value of attribute src.
Instance Method Summary collapse
-
#initialize(src, media_type = nil, attributes = {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(src, media_type = nil, attributes = {}) ⇒ Resource
Returns a new instance of Resource.
12 13 14 15 16 17 |
# File 'lib/peregrin/resource.rb', line 12 def initialize(src, media_type = nil, attributes = {}) @src = src @media_type = media_type || MIME::Types.of(File.basename(@src)) @media_type = @media_type.first if @media_type.kind_of?(Array) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/peregrin/resource.rb', line 9 def attributes @attributes end |
#media_type ⇒ Object
20 21 22 |
# File 'lib/peregrin/resource.rb', line 20 def media_type @media_type ? @media_type.to_s : nil end |
#src ⇒ Object
Returns the value of attribute src.
9 10 11 |
# File 'lib/peregrin/resource.rb', line 9 def src @src end |