class Getpics::Media
Constants
- DEVELOPED_EXTENSIONS
- MOVIE_EXTENSIONS
- RAW_EXTENSIONS
Attributes
date[RW]
extension[RW]
folder[RW]
orig_path[RW]
path[RW]
target_folder[RW]
target_name[RW]
target_path[RW]
type[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/getpics/media.rb, line 13 def initialize(path) @path = path @orig_path = path @name = File.basename(@path) @folder = File.dirname(@path) @extension = File.extname(@path) @down_case_extension = File.extname(@path).downcase if ! @name.match?(/^_/) @name = "_" + @name end begin image = MiniExiftool.new(@path) rescue puts "Error while loading #{@path}".red end begin @date = DateTime.parse(image.CreateDate.to_s) rescue puts "No valid CreateDate for #{@path}. Using mtime (#{File.mtime(@path)})".light_black @date = File.mtime(@path) end if RAW_EXTENSIONS.include?(@down_case_extension) @type = RawType.new elsif DEVELOPED_EXTENSIONS.include?(@down_case_extension) @type = DevelopedType.new elsif MOVIE_EXTENSIONS.include?(@down_case_extension) @type = MovieType.new else @type = UnknownType.new end @target_folder = "#{@type.folder}/#{year}/#{month}/#{day}/" @target_name = year_month_day + @name @target_path = @target_folder + @target_name end
Public Instance Methods
day()
click to toggle source
# File lib/getpics/media.rb, line 104 def day @date.strftime("%d") end
is_developed?()
click to toggle source
# File lib/getpics/media.rb, line 66 def is_developed? return true if @type.name == :developed return false end
is_known?()
click to toggle source
# File lib/getpics/media.rb, line 91 def is_known? return true if ! is_unknown? return false end
is_movie?()
click to toggle source
# File lib/getpics/media.rb, line 81 def is_movie? return true if @type.name == :movie return false end
is_pic?()
click to toggle source
# File lib/getpics/media.rb, line 76 def is_pic? return true if is_developed? or is_raw? return false end
is_raw?()
click to toggle source
# File lib/getpics/media.rb, line 71 def is_raw? return true if @type.name == :raw return false end
is_unknown?()
click to toggle source
# File lib/getpics/media.rb, line 86 def is_unknown? return true if @type.name == :unknown return false end
month()
click to toggle source
# File lib/getpics/media.rb, line 100 def month @date.strftime("%m") end
name()
click to toggle source
# File lib/getpics/media.rb, line 58 def name File.basename(@path) end
path=(path)
click to toggle source
# File lib/getpics/media.rb, line 54 def path=(path) @path = path end
year()
click to toggle source
# File lib/getpics/media.rb, line 96 def year @date.year end
year_month_day()
click to toggle source
# File lib/getpics/media.rb, line 108 def year_month_day @date.strftime("%Y%m%d") end