Skip to content

Commit

Permalink
Use string interpolation instead of format()
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed Oct 19, 2024
1 parent fd4c485 commit 1f41cd7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/ipaddr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ def as_json(*)
end

# Returns a json string containing the IP address representation.
def to_json(*)
format("\"%s\"", as_json)
def to_json(*a)
%Q{"#{as_json(*a)}"}
end

# Returns a string containing the IP address representation in
# cidr notation
def cidr
format("%s/%s", to_s, prefix)
"#{to_s}/#{prefix}"
end

# Returns a network byte ordered string form of the IP address.
Expand Down

0 comments on commit 1f41cd7

Please sign in to comment.