Skip to content

hamming: move inputs (strand1, strand2) to input object #1129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2018
Merged

hamming: move inputs (strand1, strand2) to input object #1129

merged 2 commits into from
Jan 16, 2018

Conversation

petertseng
Copy link
Member

hamming 2.1.0

As proposed and accepted in #996

indent = false

ARGF.each_line { |l|
  if l.include?('version')
    ver = l.split(?")[3]
    ver_components = ver.split(?.).map(&:to_i)
    ver_components[1] += 1
    ver_components[2] = 0
    l[ver] = ver_components.join(?.)
  end

  first_non_space = l.index(?")
  if l.include?('strand1')
    puts ' ' * first_non_space + '"input": {'
    indent = true
  end
  l.delete!(?,) if l.include?('strand2')
  puts "#{'  ' if indent}#{l}"
  if l.include?('strand2')
    puts ' ' * first_non_space + '},'
    indent = false
  end
}

hamming 2.1.0

As proposed and accepted in #996

```ruby
indent = false

ARGF.each_line { |l|
  if l.include?('version')
    ver = l.split(?")[3]
    ver_components = ver.split(?.).map(&:to_i)
    ver_components[1] += 1
    ver_components[2] = 0
    l[ver] = ver_components.join(?.)
  end

  first_non_space = l.index(?")
  if l.include?('strand1')
    puts ' ' * first_non_space + '"input": {'
    indent = true
  end
  l.delete!(?,) if l.include?('strand2')
  puts "#{'  ' if indent}#{l}"
  if l.include?('strand2')
    puts ' ' * first_non_space + '},'
    indent = false
  end
}
```
@petertseng petertseng merged commit 721bdd2 into exercism:master Jan 16, 2018
@petertseng petertseng deleted the ham branch January 16, 2018 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants