Class: Imash::HashData
- Inherits:
-
Object
- Object
- Imash::HashData
- Defined in:
- lib/imash/hash_data.rb
Instance Attribute Summary collapse
-
#bg ⇒ Object
readonly
Returns the value of attribute bg.
-
#fg ⇒ Object
readonly
Returns the value of attribute fg.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
Instance Method Summary collapse
-
#initialize(hash) ⇒ HashData
constructor
A new instance of HashData.
Constructor Details
#initialize(hash) ⇒ HashData
Returns a new instance of HashData.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/imash/hash_data.rb', line 6 def initialize(hash) bytes = hash.bytes.to_a @fg = convert_fg(*bytes.shift(3)) @bg = convert_bg(*bytes.shift(3)) @fg[0] = (((@bg[0].to_f / 255.0) + (@fg[0].to_f/255.0) / 3.33) * 255.0) % 255 @seed = bytes.shift(8).each_with_index.inject(0) { |a, b| a | ((b[0] & 0xFF) << b[1]*8) } end |
Instance Attribute Details
#bg ⇒ Object (readonly)
Returns the value of attribute bg.
4 5 6 |
# File 'lib/imash/hash_data.rb', line 4 def bg @bg end |
#fg ⇒ Object (readonly)
Returns the value of attribute fg.
4 5 6 |
# File 'lib/imash/hash_data.rb', line 4 def fg @fg end |
#seed ⇒ Object (readonly)
Returns the value of attribute seed.
4 5 6 |
# File 'lib/imash/hash_data.rb', line 4 def seed @seed end |