Skip to content

Commit

Permalink
Merge pull request inukshuk#8 from a-fent/proc_new_deprec_warn
Browse files Browse the repository at this point in the history
Fix warning of deprecation of Proc.new() in Ruby 2.7
  • Loading branch information
inukshuk authored Jan 7, 2020
2 parents c0668ed + f9d5a3e commit c2d6c9a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/wapiti/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def initialize(sequences = [])
@sequences = sequences
end

def each
def each(&block)
if block_given?
sequences.each(&Proc.new)
sequences.each(&block)
self
else
to_enum
Expand Down
8 changes: 4 additions & 4 deletions lib/wapiti/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def pattern=(filename)

alias native_label label

def label(input, opts = nil)
def label(input, opts = nil, &block)
unless opts.nil?
original_options = options.attributes(opts.keys)
options.update!(opts)
Expand All @@ -39,7 +39,7 @@ def label(input, opts = nil)
input = input.to_a(tagged: options.check) if input.is_a?(Dataset)

if block_given?
output = native_label(input, &Proc.new)
output = native_label(input, &block)
else
output = native_label(input)
end
Expand All @@ -61,14 +61,14 @@ def check(input)

alias native_train train

def train(tdat, ddat = nil, opts = nil)
def train(tdat, ddat = nil, opts = nil, &block)
options.update!(opts) unless opts.nil?

tdat = tdat.to_a(tagged: true) if tdat.is_a?(Dataset)
ddat = ddat.to_a(tagged: true) if ddat.is_a?(Dataset)

if block_given?
native_train(tdat, ddat, &Proc.new)
native_train(tdat, ddat, &block)
else
native_train(tdat, ddat)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/wapiti/sequence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def labels
tokens.map(&:label).uniq
end

def each
def each(&block)
if block_given?
tokens.each(&Proc.new)
tokens.each(&block)
self
else
to_enum
Expand Down

0 comments on commit c2d6c9a

Please sign in to comment.