Module: StringPresentBlank::String
- Defined in:
- lib/string_present_blank/string.rb
Instance Method Summary collapse
Instance Method Details
#blank(conditions = {}) ⇒ Object
23 24 25 |
# File 'lib/string_present_blank/string.rb', line 23 def blank(conditions={}) present(conditions) == self ? '' : self end |
#present(conditions = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/string_present_blank/string.rb', line 3 def present(conditions={}) if_condition = if conditions.has_key?(:if) conditions.delete(:if) else true end unless_condition = if conditions.has_key?(:unless) conditions.delete(:unless) else false end if if_condition and not unless_condition self else '' end end |