class Sensors::Chips
- Sensors::Chips
- Array(Sensors::Chip)
- Reference
- Object
Defined in:
chips.crClass Method Summary
- .all
- .each(match : Chip, &block : Chip -> _) : Void
-
.each(&block : Chip -> _) : Void
Calls the given block once for each element in
self
, passing that element as a parameter. - .each_with_index(match : Chip, &block : Int32, Chip -> _) : Void
-
.each_with_index(&block : Int32, Chip -> _) : Void
Iterates over the collection, yielding both the elements and their index.
- .matching(match : Chip)
Class Method Detail
Description copied from module Indexable(Sensors::Chip)
Calls the given block once for each element in self
, passing that
element as a parameter.
a = ["a", "b", "c"]
a.each { |x| print x, " -- " }
produces:
a -- b -- c --
Description copied from module Enumerable(Sensors::Chip)
Iterates over the collection, yielding both the elements and their index.
["Alice", "Bob"].each_with_index do |user, i|
puts "User ##{i}: #{user}"
end
Prints:
User # 0: Alice
User # 1: Bob
Accepts an optional offset parameter, which tells it to start counting from there. So, a more human friendly version of the previous snippet would be:
["Alice", "Bob"].each_with_index(1) do |user, i|
puts "User ##{i}: #{user}"
end
Which would print:
User # 1: Alice
User # 2: Bob