Skip to content

Commit 030620a

Browse files
committed
Merge branch 'doc/refine-readme-english' into develop
* doc/refine-readme-english: docs: refine English in README.md
2 parents 815b6f7 + 7061a4b commit 030620a

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

README.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ Or install it yourself as:
2121

2222
## Usage
2323

24-
Builds a tree by linking `CallableTree` node instances. The `call` methods of the nodes where the `match?` method returns a truthy value are called in a chain from the root node to the leaf node.
24+
Builds a tree of `CallableTree` nodes. Invokes the `call` method on nodes where `match?` returns a truthy value, chaining execution from root to leaf.
2525

2626
- `CallableTree::Node::Internal`
27-
- This `module` is used to define a node that can have child nodes. This node has several strategies (`seekable`, `broadcastable`, `composable`).
27+
- Defines a node that can have child nodes. Supports several strategies (`seekable`, `broadcastable`, `composable`).
2828
- `CallableTree::Node::External`
29-
- This `module` is used to define a leaf node that cannot have child nodes.
29+
- Defines a leaf node, which cannot have child nodes.
3030
- `CallableTree::Node::Root`
31-
- This `class` includes `CallableTree::Node::Internal`. When there is no need to customize the internal node, use this `class`.
31+
- Includes `CallableTree::Node::Internal`. Use this class when customization of the internal node is not required.
3232

3333
### Basic
3434

3535
There are two ways to define the nodes: class style and builder style.
3636

3737
#### `CallableTree::Node::Internal#seekable` (default strategy)
3838

39-
This strategy does not call the next sibling node if the `call` method of the current node returns a value other than `nil`. This behavior is changeable by overriding the `terminate?` method.
39+
This strategy stops processing subsequent sibling nodes if the current node's `call` method returns a non-nil value. This behavior is changeable by overriding the `terminate?` method.
4040

4141
##### Class style
4242

@@ -51,18 +51,15 @@ module Node
5151
File.extname(input) == '.json'
5252
end
5353

54-
# If there is need to convert the input values for
55-
# child nodes, override the `call` method.
54+
# Override `call` if you need to transform input values for child nodes.
5655
def call(input, **options)
5756
File.open(input) do |file|
5857
json = ::JSON.load(file)
5958
super(json, **options)
6059
end
6160
end
6261

63-
# If a returned value of the `call` method is `nil`,
64-
# but there is no need to call the sibling nodes,
65-
# override the `terminate?` method to return `true`.
62+
# Override `terminate?` to return `true` to stop processing sibling nodes even if `call` returns `nil`.
6663
def terminate?(_output, *_inputs, **_options)
6764
true
6865
end
@@ -94,17 +91,14 @@ module Node
9491
File.extname(input) == '.xml'
9592
end
9693

97-
# If there is need to convert the input values for
98-
# child nodes, override the `call` method.
94+
# Override `call` if you need to transform input values for child nodes.
9995
def call(input, **options)
10096
File.open(input) do |file|
10197
super(REXML::Document.new(file), **options)
10298
end
10399
end
104100

105-
# If a returned value of the `call` method is `nil`,
106-
# but there is no need to call the sibling nodes,
107-
# override the `terminate?` method to return `true`.
101+
# Override `terminate?` to return `true` to stop processing sibling nodes even if `call` returns `nil`.
108102
def terminate?(_output, *_inputs, **_options)
109103
true
110104
end
@@ -131,7 +125,7 @@ module Node
131125
end
132126
end
133127

134-
# The `seekable` method call can be omitted since it is the default strategy.
128+
# The `seekable` call can be omitted as it is the default strategy.
135129
tree = CallableTree::Node::Root.new.seekable.append(
136130
Node::JSON::Parser.new.seekable.append(
137131
Node::JSON::Scraper.new(type: :animals),
@@ -265,7 +259,7 @@ Run `examples/builder/internal-seekable.rb`:
265259

266260
#### `CallableTree::Node::Internal#broadcastable`
267261

268-
This strategy broadcasts to output a result of the child nodes as array. It also ignores their `terminate?` methods by default.
262+
This strategy broadcasts input to all child nodes and returns their results as an array. It ignores child `terminate?` methods by default.
269263

270264
##### Class style
271265

@@ -411,7 +405,7 @@ Run `examples/builder/internal-broadcastable.rb`:
411405
412406
#### `CallableTree::Node::Internal#composable`
413407
414-
This strategy composes the child nodes to input the output of the previous node into the next node and to output a result.
408+
This strategy chains child nodes, passing the output of the previous node as input to the next.
415409
It also ignores their `terminate?` methods by default.
416410
417411
##### Class style
@@ -560,7 +554,7 @@ Run `examples/builder/internal-composable.rb`:
560554
561555
#### `CallableTree::Node::External#verbosify`
562556
563-
If you want verbose output results, call this method.
557+
Use this method to enable verbose output.
564558
565559
`examples/builder/external-verbosify.rb`:
566560
```ruby
@@ -739,7 +733,7 @@ Run `examples/builder/logging.rb`:
739733
740734
#### `CallableTree::Node#identity`
741735
742-
If you want to customize the node identity, specify identifier.
736+
Specify an identifier to customize the node identity.
743737
744738
`examples/builder/identity.rb`:
745739
```ruby

0 commit comments

Comments
 (0)