class Ryb::Helpers::PrettyString
Attributes
pretty[R]
@!attribute [r] pretty @return [String] A more readable description of the string.
Public Class Methods
new(str, opts={})
click to toggle source
@param [Hash] opts Optional arguments. @param [String] str The string. @param opts [String] :pretty A more readable description of the string.
Calls superclass method
# File lib/ryb/helpers/pretty_string.rb, line 11 def initialize(str, opts={}) super(str.to_s) @pretty = opts[:pretty] if opts.include? :pretty end
Public Instance Methods
==(other)
click to toggle source
Calls superclass method
# File lib/ryb/helpers/pretty_string.rb, line 25 def ==(other) if other.is_a? String self.to_s == other.to_s else super(other) end end
Also aliased as: eql?
eql?(other)
Perform the comparision on the non-pretty values of all derivatives of strings, i.e. coerce any stringy values into ::String before comparing.
@example
greeting_1 = PrettyString.new('greeting', pretty: 'Eh!') greeting_2 = PrettyString.new('greeting', pretty: 'Aloha!') greeting_1 == greeting_2 #=> true
Alias for: ==
inspect()
click to toggle source
@return [String] A more readable description of the string.
@example
greeting = PrettyString.new("greeting", pretty: "How you doin'?") #=> "greeting" greeting.inspect #=> <Ryb::Helpers::PrettyString "greeting" @pretty: "How you doin'?">
# File lib/ryb/helpers/pretty_string.rb, line 38 def inspect if self.pretty "<#{self.class.to_s} \"#{self.to_s}\" @pretty: \"#{self.pretty}\">" else "<#{self.class.to_s} \"#{self.to_s}\">" end end