Module: Util
- Defined in:
- lib/jpcalendar/util.rb
Overview
utilクラス
Class Method Summary collapse
-
.expr_not_nil(value, &expression) ⇒ Object
}}}.
-
.is_numeric?(num) ⇒ Boolean
}}}.
-
.tag_wrap(tag, options = {}) ⇒ Object
tag_wrap {{{ 指定したタグでかこむ ブロックが渡されてない時はただのタグを生成する Railsのtagまたはcontent_tagでよかったんじゃないか説浮上。なぜ作ったのかはその時きっと疲れていたから.
Class Method Details
.expr_not_nil(value, &expression) ⇒ Object
}}}
33 34 35 36 |
# File 'lib/jpcalendar/util.rb', line 33 def expr_not_nil(value, &expression) #{{{ return nil if value.nil? || value.empty? expression.call if expression end |
.is_numeric?(num) ⇒ Boolean
}}}
26 27 28 29 30 |
# File 'lib/jpcalendar/util.rb', line 26 def is_numeric?(num) #{{{ num.to_s =~ /^[0-9]+$/ || false rescue false end |
.tag_wrap(tag, options = {}) ⇒ Object
tag_wrap {{{ 指定したタグでかこむブロックが渡されてない時はただのタグを生成するRailsのtagまたはcontent_tagでよかったんじゃないか説浮上。なぜ作ったのかはその時きっと疲れていたから
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jpcalendar/util.rb', line 13 def tag_wrap(tag,={}) attr_id = " id='#{options[:id]}'" if [:id] attr_class = " class='#{options[:class]}'" if [:class] tag = tag.to_s if tag.is_a?(Symbol) if block_given? "<#{tag + (attr_id || "") + (attr_class || "")}>#{yield}</#{tag}>" else "<#{tag} />" end end |