Module: Virginity::FieldValues::Binary

Included in:
Key, Photo, Sound
Defined in:
lib/virginity/vcard/field_values/binary.rb

Instance Method Summary collapse

Instance Method Details

#binaryObject



5
6
7
# File 'lib/virginity/vcard/field_values/binary.rb', line 5

def binary
  Base64.decode64(@value)
end

#binary=(s) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/virginity/vcard/field_values/binary.rb', line 9

def binary=(s)
  @params.delete_if { |p| p.key == "ENCODING" }
  @params << Param.new("ENCODING", "b")
  b64 = Base64.encode64(s)
  b64.delete!("\n") # can return nil... bah, but probably faster than #delete without an exclamation mark
  @value = b64
end

#sha1Object



17
18
19
# File 'lib/virginity/vcard/field_values/binary.rb', line 17

def sha1
  Digest::SHA1.hexdigest(@value)
end