Skip to content

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

Merged
petertseng merged 2 commits intoexercism:masterfrom
petertseng:ham
Jan 16, 2018
Merged

hamming: move inputs (strand1, strand2) to input object#1129
petertseng merged 2 commits intoexercism:masterfrom
petertseng:ham

Conversation

@petertseng
Copy link
Copy Markdown
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