Class: PlaySolder::Fake
- Inherits:
-
Object
- Object
- PlaySolder::Fake
- Defined in:
- lib/play_solder/fake.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #escaped_faked_file ⇒ Object
- #extension ⇒ Object
- #faked_file ⇒ Object
-
#initialize(path) ⇒ Fake
constructor
A new instance of Fake.
- #text ⇒ Object
Constructor Details
#initialize(path) ⇒ Fake
Returns a new instance of Fake.
24 25 26 |
# File 'lib/play_solder/fake.rb', line 24 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
22 23 24 |
# File 'lib/play_solder/fake.rb', line 22 def path @path end |
Class Method Details
.for_path(path) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/play_solder/fake.rb', line 8 def self.for_path(path) ext = File.extname(path) if Image::EXTENSIONS.include?(ext) Image.new(path) elsif MP3::EXTENSIONS.include?(ext) MP3.new(path) elsif Swf::EXTENSIONS.include?(ext) Swf.new(path) else raise UnfakeablePathException.new("Can't fake #{ path }") end end |
Instance Method Details
#escaped_faked_file ⇒ Object
36 37 38 |
# File 'lib/play_solder/fake.rb', line 36 def escaped_faked_file @escaped_faked_file ||= faked_file.gsub("\"", "\\\"") end |
#extension ⇒ Object
28 29 30 |
# File 'lib/play_solder/fake.rb', line 28 def extension @extension = File.extname(path) end |
#faked_file ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/play_solder/fake.rb', line 40 def faked_file if @faked_file.nil? @faked_file = "/tmp/play_solder/#{ path }" parent = Pathname.new(@faked_file).parent.to_s FileUtils.mkdir_p(parent) unless File.exist?(parent) end @faked_file end |
#text ⇒ Object
32 33 34 |
# File 'lib/play_solder/fake.rb', line 32 def text @text ||= File.basename(path).gsub(extension, "") end |