module CF::Refinements

Public Instance Methods

binary!(bin = true) click to toggle source

@param [optional, Boolean, Encoding] bin If you pass ‘true` then `Encoding::ASCII_BIT` is used, if you pass `false` then `Encoding::UTF_8`

# File lib/corefoundation/refinements.rb, line 75
def binary!(bin = true)
  if bin == true
    force_encoding Encoding::ASCII_8BIT
  else
    # default to utf-8
    force_encoding(bin == false ? "UTF-8" : bin)
  end
  self
end
binary?() click to toggle source

@!method binary?

used to determine whether {#to_cf} should return a {CF::String} or a {CF::Data}. This simply checks whether the encoding is ascii-8bit or not.

@return whether the string is handled as binary data or not

# File lib/corefoundation/refinements.rb, line 69
def binary?
  encoding == Encoding::ASCII_8BIT
end
to_cf() click to toggle source

Converts the Integer to a {CF::Number} using {CF::Number.from_i} @return [CF::Number]

# File lib/corefoundation/refinements.rb, line 9
def to_cf
  CF::Number.from_i(self)
end
to_cf_data() click to toggle source

Returns a {CF::Data} representing the string @return [CF::Data]

# File lib/corefoundation/refinements.rb, line 93
def to_cf_data
  CF::Data.from_string self
end
to_cf_string() click to toggle source

Returns a {CF::String} representing the string @return [CF::String]

# File lib/corefoundation/refinements.rb, line 87
def to_cf_string
  CF::String.from_string self
end