lib/app_info/file.rb in app-info-3.0.0.beta1 vs lib/app_info/file.rb in app-info-3.0.0.beta2

- old
+ new

@@ -8,16 +8,42 @@ def initialize(file, logger: AppInfo.logger) @file = file @logger = logger end - # @abstract Subclass and override {#file_type} to implement - def file_type - Platform::UNKNOWN + # @return [Symbol] {Format} + def format + @format ||= lambda { + if instance_of?(AppInfo::File) || instance_of?(AppInfo::Apple) || + instance_of?(AppInfo::Android) + not_implemented_error!(__method__) + end + + self.class.name.split('::')[-1].downcase.to_sym + }.call end + # @abstract Subclass and override {#opera_system} to implement. + def opera_system + not_implemented_error!(__method__) + end + + # @abstract Subclass and override {#platform} to implement. + def platform + not_implemented_error!(__method__) + end + + # @abstract Subclass and override {#device} to implement. + def device + not_implemented_error!(__method__) + end + # @abstract Subclass and override {#size} to implement def size(human_size: false) - raise NotImplementedError, ".#{__method__} method implantation required in #{self.class}" + not_implemented_error!(__method__) + end + + def not_implemented_error!(method) + raise NotImplementedError, ".#{method} method implantation required in #{self.class}" end end end