class SchemaToScaffold::Clipboard

Attributes

output[R]

Public Class Methods

new(output) click to toggle source
# File lib/schema_to_scaffold/clipboard.rb, line 5
def initialize(output)
  @output = output
end

Public Instance Methods

command() click to toggle source
# File lib/schema_to_scaffold/clipboard.rb, line 9
def command
  case platform
    when /darwin/i then darwin_command
    when /linux/i  then linux_command
    when /mingw/i  then win_command
    when /win/i    then win_command
  end
end

Private Instance Methods

darwin_command() click to toggle source
# File lib/schema_to_scaffold/clipboard.rb, line 20
def darwin_command
  exec("echo '#{output}' | tr -d '\n' | pbcopy")
end
linux_command() click to toggle source
# File lib/schema_to_scaffold/clipboard.rb, line 24
def linux_command
  exec("echo '#{output}' | tr -d '\n' | xclip -selection c")
end
platform() click to toggle source
# File lib/schema_to_scaffold/clipboard.rb, line 32
def platform
  RUBY_PLATFORM
end
win_command() click to toggle source
# File lib/schema_to_scaffold/clipboard.rb, line 28
def win_command
  exec("echo '#{output}' | clip")
end