Method: ListTool::Item#initialize
- Defined in:
- lib/list_tool/item.rb
#initialize(arg) ⇒ Item
Returns a new instance of Item.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/list_tool/item.rb', line 6 def initialize arg if arg.is_a?(String) @text = arg elsif arg.is_a?(Hash) raise(ArgumentError, "item text not found in given hash") unless arg['text'].is_a?(String) @text = arg["text"] else raise(ArgumentError, "argument expected to be Hash or String, #{arg.class} given") end end |