Class: Ro::Node::Asset

Inherits:
String
  • Object
show all
Defined in:
lib/ro/node.rb

Constant Summary collapse

IMAGE_RE =
%r/[.](jpg|jpeg|png|gif|tif|tiff)$/i

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Asset.



157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/ro/node.rb', line 157

def initialize(name, options = {})
  super(name)
ensure
  options = Map.for(options)

  Asset.fattrs.each do |attr|
    if options.has_key?(attr)
      value = options[attr]
      send(attr, value)
    end
  end
end

Instance Method Details

#basenameObject



186
187
188
# File 'lib/ro/node.rb', line 186

def basename
  File.basename(path.to_s)
end

#extensionObject Also known as: ext



180
181
182
183
# File 'lib/ro/node.rb', line 180

def extension
  base, ext = basename.split('.', 2)
  ext
end

#image?Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/ro/node.rb', line 176

def image?
  !!(self =~ IMAGE_RE)
end

#nameObject



170
171
172
# File 'lib/ro/node.rb', line 170

def name
  self
end