Module: MooTool::Formatters

Defined in:
lib/mootool/formatters.rb,
lib/mootool/formatters/ec_public_key.rb,
lib/mootool/formatters/ecc_signature.rb,
lib/mootool/formatters/digest_formatter.rb,
lib/mootool/formatters/ec_point_formatter.rb,
lib/mootool/formatters/pathname_formatter.rb,
lib/mootool/formatters/certificate_formatter.rb,
lib/mootool/formatters/ecc_encryption_formatter.rb,
lib/mootool/formatters/firmware_entry_formatter.rb

Defined Under Namespace

Modules: CertificateFormatter, DigestFormatter, ECCEncryptionFormatter, ECCSignature, ECPointFormatter, ECPublicKey, FirmwareEntryFormatter, PathnameFormatter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
# File 'lib/mootool/formatters.rb', line 5

def self.included(base)
  base.send :alias_method, :cast_without_formatters, :cast
  base.send :alias_method, :cast, :cast_with_formatters
end

Instance Method Details

#awesome_any_value(_input) ⇒ Object



39
40
41
# File 'lib/mootool/formatters.rb', line 39

def awesome_any_value(_input)
  colorize('*** SPLAT ***', :trueclass)
end

#awesome_path(object) ⇒ Object



43
44
45
# File 'lib/mootool/formatters.rb', line 43

def awesome_path(object)
  colorize(object.to_s, :path)
end

#awesome_uuid(object) ⇒ Object



47
48
49
# File 'lib/mootool/formatters.rb', line 47

def awesome_uuid(object)
  colorize(object.to_s, :uuid)
end

#cast_with_formatters(object, type) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mootool/formatters.rb', line 10

def cast_with_formatters(object, type)
  cast = cast_without_formatters(object, type)

  case object
  when Pathname
    :path
  when UUIDTools::UUID
    :uuid
  when OpenSSL::PKey::EC::Point
    :point
  when MooTool::Models::IMG4::FirmwareEntry
    :firmware_entry
  when MooTool::Models::Digest
    :digest
  when MooTool::Models::Certificate
    :certificate
  when MooTool::Models::ECCPublicKey
    :ecc_public_key
  when MooTool::Models::ECCSignature
    :ecc_signature
  when MooTool::Models::ECIESEncryption
    :ecc_encryption
  when :ALLOW_ANY_VALUE
    :any_value
  else
    cast
  end
end