Module: PositiveBasicSupport::BasicObjectExt
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/positive_basic_support/basic_object_ext.rb
Defined Under Namespace
Modules: ClassMethods
クラスの判定 - 数値 collapse
-
#integer? ⇒ Boolean
整数か否かを判定するメソッド.
-
#natural_number?(include_zero: false) ⇒ Boolean
自然数か否かを判定するメソッド.
-
#natural_number_including_zero? ⇒ Boolean
(also: #natural_number_or_zero?)
「自然数または0」か否かを判定するメソッド(0 に対しても true を返す).
-
#number? ⇒ Boolean
数値か否かを判定するメソッド.
クラスの判定 - 文字列 collapse
-
#string?(include_subclasses: false) ⇒ Boolean
文字列(String クラスのインスタンス)か否かを判定するメソッド.
クラスの判定 - シンボル collapse
-
#symbol? ⇒ Boolean
Symbol クラスのインスタンスか否かを判定するメソッド.
クラスの判定 - 文字列・シンボル collapse
-
#string_or_symbol?(include_subclasses: false) ⇒ Boolean
String クラスまたは Symbol クラスのインスタンスか否かを判定するメソッド.
クラスの判定 - 正規表現 collapse
クラスの判定 - 配列 collapse
クラスの判定 - 真偽値 collapse
-
#boolean? ⇒ Boolean
真偽値か否かを判定するメソッド.
-
#boolean_or_nil? ⇒ Boolean
「真偽値または nil 」か否かを判定するメソッド.
Instance Method Details
#array?(include_subclasses: false) ⇒ Boolean
230 231 232 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 230 def array?( include_subclasses: false ) class_decision( ::Array , include_subclasses ) end |
#boolean? ⇒ Boolean
真偽値か否かを判定するメソッド
249 250 251 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 249 def boolean? instance_of?( ::TrueClass ) or instance_of?( ::FalseClass ) end |
#boolean_or_nil? ⇒ Boolean
「真偽値または nil 」か否かを判定するメソッド
262 263 264 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 262 def boolean_or_nil? boolean? or nil? end |
#hash? ⇒ Boolean
234 235 236 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 234 def hash? instance_of?( ::Hash ) end |
#integer? ⇒ Boolean
整数か否かを判定するメソッド
97 98 99 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 97 def integer? kind_of?( ::Integer ) end |
#natural_number?(include_zero: false) ⇒ Boolean
Note:
内部で #natural_number_including_zero? , #natural_number_except_for_zero? を利用している.
自然数か否かを判定するメソッド
129 130 131 132 133 134 135 136 137 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 129 def natural_number?( include_zero: false ) include_zero.should_be( :boolean , variable_name: :include_zero ) if include_zero natural_number_including_zero? else natural_number_except_for_zero? end end |
#natural_number_including_zero? ⇒ Boolean Also known as: natural_number_or_zero?
「自然数または0」か否かを判定するメソッド(0 に対しても true を返す)
152 153 154 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 152 def natural_number_including_zero? integer? and self >= 0 end |
#number? ⇒ Boolean
数値か否かを判定するメソッド
82 83 84 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 82 def number? kind_of?( ::Numeric ) end |
#regexp? ⇒ Boolean
224 225 226 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 224 def regexp? instance_of?( ::Regexp ) end |
#string?(include_subclasses: false) ⇒ Boolean
文字列(String クラスのインスタンス)か否かを判定するメソッド
172 173 174 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 172 def string?( include_subclasses: false ) class_decision( ::String , include_subclasses ) end |
#string_or_symbol?(include_subclasses: false) ⇒ Boolean
String クラスまたは Symbol クラスのインスタンスか否かを判定するメソッド
219 220 221 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 219 def string_or_symbol?( include_subclasses: false ) string?( include_subclasses: include_subclasses ) or symbol? end |
#symbol? ⇒ Boolean
Symbol クラスのインスタンスか否かを判定するメソッド
195 196 197 |
# File 'lib/positive_basic_support/basic_object_ext.rb', line 195 def symbol? instance_of?( ::Symbol ) end |