Class: Assets::Evaluator

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
lib/assets/evaluator.rb

Overview

Rule evaluator

Instance Method Summary collapse

Instance Method Details

#assetAsset

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return asset

Returns:



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/assets/evaluator.rb', line 13

def asset
  rule = self.rule
  Asset.new(
    :name       => rule.name,
    :mime       => rule.mime,
    :created_at => Time.now,
    :body       => body,
    :size       => size,
    :sha1       => sha1
  )
end

#bodyString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return body

Returns:

  • (String)


41
42
43
# File 'lib/assets/evaluator.rb', line 41

def body
  rule.body
end

#mimeMime

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return mime

Returns:



62
63
64
# File 'lib/assets/evaluator.rb', line 62

def mime
  rule.mime
end

#sha1String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return sha1 hexdigest of body

Returns:

  • (String)


31
32
33
# File 'lib/assets/evaluator.rb', line 31

def sha1
  Digest::SHA1.hexdigest(body)
end

#sizeFixnum

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return size in bytes

Returns:

  • (Fixnum)


52
53
54
# File 'lib/assets/evaluator.rb', line 52

def size
  body.bytesize
end