Module: PdfTemplator
- Defined in:
- lib/pdf_templator.rb,
lib/pdf_templator/type.rb,
lib/pdf_templator/types.rb,
lib/pdf_templator/reader.rb,
lib/pdf_templator/version.rb,
lib/pdf_templator/formatter.rb
Defined Under Namespace
Classes: AccountingType, DateType, Formatter, MoneyType, NumberType, NumericType, Reader, TextType, Type
Constant Summary collapse
- VERSION =
'0.0.1'
Class Method Summary collapse
-
.string_to_type(string) ⇒ Object
Example:.
-
.string_to_type_class(string) ⇒ Object
Example:.
Class Method Details
.string_to_type(string) ⇒ Object
Example:
Slop.string_to_type("string") #=> "StringType"
Slop.string_to_type("some_thing") #=> "SomeThingType"
Returns a camel-cased class looking string with Type suffix.
16 17 18 |
# File 'lib/pdf_templator.rb', line 16 def self.string_to_type(string) string.to_s.gsub(/(?:^|_)([a-z])/) { Regexp.last_match(1).capitalize } + 'Type' end |
.string_to_type_class(string) ⇒ Object
Example:
Slop.string_to_type_class("string") #=> Slop::StringType
Slop.string_to_type_class("foo") #=> uninitialized constant FooType
Returns the full qualified type class. Uses ‘#string_to_type`.
26 27 28 |
# File 'lib/pdf_templator.rb', line 26 def self.string_to_type_class(string) const_get(string_to_type(string)) end |