Skip to content

Commit

Permalink
Minor documentation fixes
Browse files Browse the repository at this point in the history
* Make it clear that Row#each iterates over Tabulo#Cell
* Describe configurability of truncation indicator at a more logical
  point in the README
* Fix spec wording with regards to Row#each method
* It's Cell#formatted_content, not #formatted_value
  • Loading branch information
matt-harvey committed Nov 12, 2019
1 parent 3ad2dc1 commit bf0b596
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ table = Tabulo::Table.new(
+--------------+--------------+
```

The character used to indicate truncation, which defaults to `~`, can be configured using the
`truncation_indicator` option passed to `Table.new`.

<a name="formatting-cell-values"></a>
### Formatting cell values

Expand Down Expand Up @@ -422,9 +425,6 @@ Note the numbers in the "Reciprocal" column in this example are still right-alig
the callable passed to `formatter` returns a String. Default cell alignment is determined by the type
of the underlying cell value, not the way it is formatted. This is usually the desired result.

Note also that the item yielded to `.each` for each cell when enumerating over a `Tabulo::Row` is
the underlying value of that cell, not its formatted value.

<a name="colours-and-styling"></a>
### Colours and styling

Expand Down Expand Up @@ -553,7 +553,7 @@ calculated.)

Each `Tabulo::Table` is an `Enumerable` of which each element is a `Tabulo::Row`. Each `Tabulo::Row`
is itself an `Enumerable`, of `Tabulo::Cell`. The `Tabulo::Cell#value` method will return the
underlying value of the cell; while `Tabulo::Cell#formatted_value` will return its formatted content
underlying value of the cell; while `Tabulo::Cell#formatted_content` will return its formatted content
as a string.

A `Tabulo::Row` can also
Expand Down Expand Up @@ -719,12 +719,6 @@ but without a bottom border:
| 3 | false | true |
```

<a name="additional-configuration-options"></a>
### Other configuration options

The character used to indicate truncation, which defaults to `~`, can be configured using the
`truncation_indicator` option passed to `Table.new`.

<a name="motivation"></a>
## Comparison with other libraries

Expand Down
6 changes: 2 additions & 4 deletions lib/tabulo/row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ def initialize(table, source, header: :top)
@header = header
end

# Calls the given block once for each cell in the {Row}, passing that cell as parameter.
# Each "cell" is just the calculated value for its column (pre-formatting) for this {Row}'s
# source item.
# Calls the given block once for each {Cell} in the {Row}, passing that {Cell} as parameter.
#
# @example
# table = Tabulo::Table.new([1, 10], columns: %i(itself even?))
# row = table.first
# row.each do |cell|
# puts cell # => 1, => false
# puts cell.value # => 1, => false
# end
def each
@table.column_registry.each do |_, column|
Expand Down
2 changes: 1 addition & 1 deletion spec/row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
expect(i).to eq(2)
end

it "iterates over the results of calling the column's extractor on the source object",
it "iterates over Cells that wrap the value derived by calling the column's extractor on the source object",
:aggregate_failures do

row.each_with_index do |cell, i|
Expand Down

0 comments on commit bf0b596

Please sign in to comment.