def is_a_number?(s)
s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil? false : true
end
s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil? false : true
end
| operand | what it does |
|---|---|
| << | append (in context of strings, arrays, IO); shift position of bits in Bignum and Fixnum |
| >> | shift position of bits in Bignum and Fixnum |
| ~ | bitwise NOT (high-presendence) |
| & | bitwise AND (medium-presendence) |
| | | bitwise OR (medium-presendence) |
| ^ | bitwise XOR (medium-presendence) |
| ** | exponent |
| + | addition |
| - | subtraction |
| * | multiplication |
| / | division |
| % | modulo operator |
A method defined on a model that ends with = is an assignment method, so when ActiveRecord is trying to save an attribute to this model, you can define a custom action to perform the save. Useful, for example, when passing a hash to this model for some list of things that is not part of active record.
Some handy information about working with those less-than-percent sign things that appear in Emulated Ruby, or .rhtml files.
| example | what it does |
|---|---|
| <% ... %> | evaluate/execute ruby code |
| <%= ... %> | evaluate & return to buffer (result will be included in output) |
| <%- ... %> | strip whitespace before tag |
| <% ... -%> | strip whitespace after tag |