Skip to content

Commit

Permalink
Add inline documentation to describe each class
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Huber committed Jun 12, 2015
1 parent 82ff934 commit 5bb5534
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/sub_diff/adapter.rb
@@ -1,4 +1,10 @@
module SubDiff
# Constructs an instance of {Sub} or {Gsub} to be
# used as a receiver for delegated calls to `diff`.
#
# Used internally by {Builder}.
#
# @api private
class Adapter
extend Forwardable

Expand Down
6 changes: 6 additions & 0 deletions lib/sub_diff/builder.rb
@@ -1,4 +1,10 @@
module SubDiff
# Performs a {Sub} or {Gsub} replacement and returns
# the resulting {Collection} of {Diff} objects.
#
# Used internally by {String#sub_diff} and {String#gsub_diff}.
#
# @api private
class Builder
attr_reader :string, :diff_method

Expand Down
7 changes: 7 additions & 0 deletions lib/sub_diff/collection.rb
@@ -1,4 +1,11 @@
module SubDiff
# Stores a collection of {Diff} objects for all matches
# from {String#sub_diff} or {String#gsub_diff} replacement.
#
# It behaves like a {String} with added {Enumerable} behavior
# that delegates to an internal {Array} of {Diff} objects.
#
# @api public
class Collection < SimpleDelegator
extend Forwardable
include Enumerable
Expand Down
9 changes: 9 additions & 0 deletions lib/sub_diff/diff.rb
@@ -1,4 +1,13 @@
module SubDiff
# Stores a single match (and optional replacement)
# from {String#sub} or {String#gsub} replacements.
#
# It behaves just like a {String} but has some additional
# methods that provides references to the old string,
# the newly replaced string, and a boolean to check
# if a replacement was actually made.
#
# @api public
class Diff < SimpleDelegator
attr_reader :value_was

Expand Down
6 changes: 6 additions & 0 deletions lib/sub_diff/differ.rb
@@ -1,4 +1,10 @@
module SubDiff
# Performs a {String#sub} or {String#gsub} replacement
# while yielding each match to a block.
#
# Used internally by {Sub}.
#
# @api private
class Differ
extend Forwardable

Expand Down
6 changes: 6 additions & 0 deletions lib/sub_diff/gsub.rb
@@ -1,4 +1,10 @@
module SubDiff
# Processes matches for {String#gsub} replacements
# to build up a {Collection} of {Diff} objects.
#
# Used internally by {Adapter}.
#
# @api private
class Gsub < Sub
private

Expand Down
6 changes: 6 additions & 0 deletions lib/sub_diff/sub.rb
@@ -1,4 +1,10 @@
module SubDiff
# Processes matches for {String#sub} replacements
# to build up a {Collection} of {Diff} objects.
#
# Used internally by {Adapter}.
#
# @api private
class Sub
attr_reader :differ

Expand Down

0 comments on commit 5bb5534

Please sign in to comment.