Class: PopCap::Formatters::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/pop_cap/formatter.rb

Overview

Public: This is a super class for all formatter classes. It establishes the default behavior of formatter classes.

Direct Known Subclasses

BitRate, Date, Duration, Filesize

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, options = {}) ⇒ Formatter

Public: This class is constructed with a value & options hash.

value - The value to be formatted. options - An options hash.



14
15
16
# File 'lib/pop_cap/formatter.rb', line 14

def initialize(value, options={})
  @value, @options = value, options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/pop_cap/formatter.rb', line 7

def options
  @options
end

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/pop_cap/formatter.rb', line 7

def value
  @value
end

Class Method Details

.format(value, options = {}) ⇒ Object

Public: A class method for convenience calling of #format.



25
26
27
# File 'lib/pop_cap/formatter.rb', line 25

def self.format(value, options={})
  new(value, options).format
end

.subclassesObject

Public: This returns an array of all subclasses.



31
32
33
34
35
36
37
# File 'lib/pop_cap/formatter.rb', line 31

def self.subclasses
  require_all_formatters

  ObjectSpace.each_object(Class).select do |klass|
    klass if is_a_subclass?(klass)
  end.uniq.compact
end

.subclasses_demodulizedObject

Public: This returns an array of all subclasses “demodulized.”



41
42
43
# File 'lib/pop_cap/formatter.rb', line 41

def self.subclasses_demodulized
  subclasses.map { |klass| demodulize(klass) }
end

Instance Method Details

#formatObject

Public: This method contains the handles the formating.



20
21
# File 'lib/pop_cap/formatter.rb', line 20

def format
end