Skip to content

Instantly share code, notes, and snippets.

@aurelian
Created March 22, 2011 12:22
Show Gist options
  • Save aurelian/881130 to your computer and use it in GitHub Desktop.
Save aurelian/881130 to your computer and use it in GitHub Desktop.
tag += (sequence == 0)? '.1' : ((sequence < 0)? '' : ("."+(sequence+1).to_s)
@tmacedo
Copy link

tmacedo commented Mar 22, 2011

tag += if sequence == 0
  '.1'
elsif sequence > 0
  ".#{sequence + 1}"
else
  ''
end

@HakubJozak
Copy link

I think encapsulating it into some VersionCounter would be the best ... but

tag += (sequence == 0) ? '1' : next_version(sequence)

def next_version(sequence)
   if sequence > 0
     ("."+(sequence+1).to_s)
   else
    ''
   end
 end

@HakubJozak
Copy link

tiago won

@tmacedo
Copy link

tmacedo commented Mar 22, 2011

  tag += (sequence >= 0)? "."+(sequence+1).to_s : ''

@aurelian
Copy link
Author

this: tag += (sequence >= 0)? "."+(sequence+1).to_s : ''
is winning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment