Since you noted your question “Linux”, I would go for something like:
who | cut -f2 -d " "
console
ttys000
Or inside irb:
$ irb
1.9.3p194 :001 > exec 'who | cut -f2 -d " "'
console
ttys000
see also: Other options for running a shell command .
, Etc:
$ irb
1.9.3p194 :001 > require 'etc'
=> true
1.9.3p194 :002 > Etc.getlogin
=> "DudeRoot"
- .c, , , github.