Module: PlainText::Part::StringType
Overview
Contains common methods for use in the String-type classes.
Instance Method Summary collapse
-
#clone ⇒ PlainText::Part
Work around because Object#clone does not clone the instance variable @string.
-
#dup ⇒ PlainText::Part
Work around because Object#dup does not dup the instance variable @string.
-
#inspect ⇒ String
Para(“abncd”) or Boundary(“nnn”).
-
#method_missing(method_name, *args, **kwds) ⇒ Object
Basically delegates everything to String.
-
#respond_to_missing?(method_name, *rest) ⇒ Boolean
Redefines the behaviour of
respond_to?
(essential when definingmethod_missing
). - #to_s ⇒ String (also: #to_str, #instance)
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, **kwds) ⇒ Object
Basically delegates everything to String
22 23 24 25 |
# File 'lib/plain_text/part/string_type.rb', line 22 def method_missing(method_name, *args, **kwds) ret = to_s.public_send(method_name, *args, **kwds) ret.respond_to?(:to_str) ? self.class.new(ret) : ret end |
Instance Method Details
#clone ⇒ PlainText::Part
Work around because Object#clone does not clone the instance variable @string
71 72 73 |
# File 'lib/plain_text/part/string_type.rb', line 71 def clone dup_or_clone(super, __method__, '@string') # defined in builtin_type.rb end |
#dup ⇒ PlainText::Part
Work around because Object#dup does not dup the instance variable @string
64 65 66 |
# File 'lib/plain_text/part/string_type.rb', line 64 def dup dup_or_clone(super, __method__, '@string') # defined in builtin_type.rb end |
#inspect ⇒ String
Para(“abncd”) or Boundary(“nnn”)
35 36 37 38 |
# File 'lib/plain_text/part/string_type.rb', line 35 def inspect s = self.class.name sprintf "%s(%s)", (s.split('::')[2..-1].join('::') rescue s), to_s.inspect end |
#respond_to_missing?(method_name, *rest) ⇒ Boolean
Redefines the behaviour of respond_to?
(essential when defining method_missing
)
28 29 30 |
# File 'lib/plain_text/part/string_type.rb', line 28 def respond_to_missing?(method_name, *rest) # include_all=false to_s.respond_to?(method_name, *rest) || super end |
#to_s ⇒ String Also known as: to_str, instance
15 16 17 |
# File 'lib/plain_text/part/string_type.rb', line 15 def to_s @string end |