Class: Array
Instance Method Summary collapse
- #of(unit) ⇒ Object
- #resize(new_size, filler = nil) ⇒ Object
-
#to_attrs ⇒ Object
Convert array of function parameters to a single attributes hash.
Instance Method Details
#of(unit) ⇒ Object
296 297 298 |
# File 'lib/kiss/ext/core.rb', line 296 def of(unit) size.of(unit) end |
#resize(new_size, filler = nil) ⇒ Object
300 301 302 303 304 305 306 307 308 |
# File 'lib/kiss/ext/core.rb', line 300 def resize(new_size, filler = nil) current_size = size if new_size < current_size slice!(new_size, current_size) else fill(filler, current_size, new_size - current_size) end self end |
#to_attrs ⇒ Object
Convert array of function parameters to a single attributes hash. Each parameter must be a Symbol, except for the last, which may be a Symbol or an attributes hash.
313 314 315 316 317 |
# File 'lib/kiss/ext/core.rb', line 313 def to_attrs attrs = last.is_a?(Hash) ? pop : {} self.each {|arg| attrs[arg] = true } attrs end |