* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: Unicorn's Ruby Questions and Programs  (Read 2202 times)

0 Members and 1 Guest are viewing this topic.

Offline Unicorn

  • PICKACHUP IS LYFE
  • Super User
  • CW Contest II - 2nd place
  • *
  • Join Date: Jan 2015
  • Location: PICKACHUP land
  • Posts: 2715
  • Post Rating Ratio: +5/-2
  • make :PICKACHUP: a thing!
    • Unicorn808
    • 114/11432
    • View Profile
    • UnicornCalcs
  • Gender: Male
Unicorn's Ruby Questions and Programs
« on: July 18, 2015, 05:33:48 pm »
So, I decided to make a question/display thread about ruby. I am currently trying to make a guessing game, sticking with the first game I made in TI-BASIC :P

Anyways, I'll ask questions here and showcase my programs, and maybe post downloads. :)

EDIT: A little input and display program:

Code: (Input/Display) [Select]
while 1
puts 'Type whatever you want here!'
text = gets.chomp
puts text
if text == 'Quit'
    abort
end
end

Also, a guessing game :)
If you have ruby installed, run the attached file.
Else, install it :P

Code: [Select]
guess = 10000
puts 'Guess a number from 0 to 50!'
number = rand(50)
while guess > 0
  guess = gets.to_i
  if guess == number
    puts 'Great job! You guessed the number!'
    abort
  elsif guess > number
    puts 'That is not the right number.'
    puts 'Try again, with a LOWER number'
  elsif guess < number
    puts 'That is not the right number.'
    puts 'Try again, with a HIGHER number'
  end
end
« Last Edit: July 19, 2015, 01:42:13 pm by Unicorn »


  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something
  • Consoles, mobile devices and vintage computers owned: PICKACHUP



Offline alexgt

  • Just your friendly neighborhood Ninja Stach Fancy Iron Man
  • Super User
  • Join Date: Dec 2014
  • Location: Behind you
  • Posts: 2610
  • Post Rating Ratio: +6/-1
  • Something should go here...
    • /u/alexgt9123
    • View Profile
  • Gender: Male
Re: Unicorn's Ruby Questions and Programs
« Reply #1 on: July 19, 2015, 12:03:04 am »
O.o ruby looks quite like HP PPL as far as syntax I think I might give a shot at learning it, I hope you succeed Unicorn :)
  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

Offline Unicorn

  • PICKACHUP IS LYFE
  • Super User
  • CW Contest II - 2nd place
  • *
  • Join Date: Jan 2015
  • Location: PICKACHUP land
  • Posts: 2715
  • Post Rating Ratio: +5/-2
  • make :PICKACHUP: a thing!
    • Unicorn808
    • 114/11432
    • View Profile
    • UnicornCalcs
  • Gender: Male
Re: Unicorn's Ruby Questions and Programs
« Reply #2 on: July 19, 2015, 12:26:24 am »
Yeah, I like how much it is like a basic language. Another good thing, is that there are a few ruby dev environments in the cloud, like cloud9 :)
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something
  • Consoles, mobile devices and vintage computers owned: PICKACHUP



Offline Strontium

  • Full User
  • Join Date: Apr 2015
  • Location: CA
  • Posts: 220
  • Post Rating Ratio: +2/-2
  • hey
    • Unilunge
    • thelinethatmarkstheend
    • /u/thismarkstheend
    • Azmarok
    • View Profile
  • Gender: Female
Re: Unicorn's Ruby Questions and Programs
« Reply #3 on: July 19, 2015, 01:01:03 am »
(click to show/hide)

Yeah, I like how much it is like a basic language. Another good thing, is that there are a few ruby dev environments in the cloud, like cloud9 :)
Lots of languages have online environments. Even Haskell <3
  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES
FRC 4711 represent

Offline Unicorn

  • PICKACHUP IS LYFE
  • Super User
  • CW Contest II - 2nd place
  • *
  • Join Date: Jan 2015
  • Location: PICKACHUP land
  • Posts: 2715
  • Post Rating Ratio: +5/-2
  • make :PICKACHUP: a thing!
    • Unicorn808
    • 114/11432
    • View Profile
    • UnicornCalcs
  • Gender: Male
Re: Unicorn's Ruby Questions and Programs
« Reply #4 on: July 19, 2015, 01:11:48 am »
lol, yeah, thats true.

Thanks for fixig that, I guess it didnt sav it when copy/pasting. I'll paste itnin tomorrow :)
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something
  • Consoles, mobile devices and vintage computers owned: PICKACHUP



Offline alexgt

  • Just your friendly neighborhood Ninja Stach Fancy Iron Man
  • Super User
  • Join Date: Dec 2014
  • Location: Behind you
  • Posts: 2610
  • Post Rating Ratio: +6/-1
  • Something should go here...
    • /u/alexgt9123
    • View Profile
  • Gender: Male
Re: Unicorn's Ruby Questions and Programs
« Reply #5 on: July 19, 2015, 01:56:55 am »
The one  thing I dislike about on calc editing is it is hard to inddent <_< I should add that to SIFS prog editor O.O
  • Calculators owned: Ti-84+, Ti-Nspire, Hp Prime, Broken HP Prime, HP 48SX

Offline Unicorn

  • PICKACHUP IS LYFE
  • Super User
  • CW Contest II - 2nd place
  • *
  • Join Date: Jan 2015
  • Location: PICKACHUP land
  • Posts: 2715
  • Post Rating Ratio: +5/-2
  • make :PICKACHUP: a thing!
    • Unicorn808
    • 114/11432
    • View Profile
    • UnicornCalcs
  • Gender: Male
Re: Unicorn's Ruby Questions and Programs
« Reply #6 on: July 19, 2015, 02:24:04 am »
Good idea! But be reminded, this wasn't on calc. ;)
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something
  • Consoles, mobile devices and vintage computers owned: PICKACHUP



Offline Strontium

  • Full User
  • Join Date: Apr 2015
  • Location: CA
  • Posts: 220
  • Post Rating Ratio: +2/-2
  • hey
    • Unilunge
    • thelinethatmarkstheend
    • /u/thismarkstheend
    • Azmarok
    • View Profile
  • Gender: Female
Re: Unicorn's Ruby Questions and Programs
« Reply #7 on: July 19, 2015, 03:43:52 am »
Good idea! But be reminded, this wasn't on calc. ;)

It would be great if there were ARM powered calculators that ran a *nix OS (probably BSD. That seems like a good fit for a calculator!) so you could use any language you wanted without having to do much work porting, as well as use many programs targeted at desktop devices.
now I know what I should do with a future computer science degree :)
  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES
FRC 4711 represent

Offline Unicorn

  • PICKACHUP IS LYFE
  • Super User
  • CW Contest II - 2nd place
  • *
  • Join Date: Jan 2015
  • Location: PICKACHUP land
  • Posts: 2715
  • Post Rating Ratio: +5/-2
  • make :PICKACHUP: a thing!
    • Unicorn808
    • 114/11432
    • View Profile
    • UnicornCalcs
  • Gender: Male
Re: Unicorn's Ruby Questions and Programs
« Reply #8 on: July 19, 2015, 03:46:40 am »
You could sell designs to TI or HP or Casio :P
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something
  • Consoles, mobile devices and vintage computers owned: PICKACHUP



Offline Strontium

  • Full User
  • Join Date: Apr 2015
  • Location: CA
  • Posts: 220
  • Post Rating Ratio: +2/-2
  • hey
    • Unilunge
    • thelinethatmarkstheend
    • /u/thismarkstheend
    • Azmarok
    • View Profile
  • Gender: Female
Re: Unicorn's Ruby Questions and Programs
« Reply #9 on: July 19, 2015, 04:05:54 am »
You could sell designs to TI or HP or Casio :P

I don't think any of them will listen. Especially TI.
  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES
FRC 4711 represent

Online Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 2661
  • Post Rating Ratio: +17/-1
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • View Profile
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: Unicorn's Ruby Questions and Programs
« Reply #10 on: July 19, 2015, 05:13:29 am »
Good idea! But be reminded, this wasn't on calc. ;)

It would be great if there were ARM powered calculators that ran a *nix OS (probably BSD. That seems like a good fit for a calculator!) so you could use any language you wanted without having to do much work porting, as well as use many programs targeted at desktop devices.
now I know what I should do with a future computer science degree :)
* Juju points to Nspire Linux >.>
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)

In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii:

YUKI-CHAAAANNNN

Offline Strontium

  • Full User
  • Join Date: Apr 2015
  • Location: CA
  • Posts: 220
  • Post Rating Ratio: +2/-2
  • hey
    • Unilunge
    • thelinethatmarkstheend
    • /u/thismarkstheend
    • Azmarok
    • View Profile
  • Gender: Female
Re: Unicorn's Ruby Questions and Programs
« Reply #11 on: July 19, 2015, 05:27:54 am »
Good idea! But be reminded, this wasn't on calc. ;)

It would be great if there were ARM powered calculators that ran a *nix OS (probably BSD. That seems like a good fit for a calculator!) so you could use any language you wanted without having to do much work porting, as well as use many programs targeted at desktop devices.
now I know what I should do with a future computer science degree :)
* Juju points to Nspire Linux >.>

Thats not officially supported though, and it looks like a pain in the ass to use.
  • Calculators owned: TI Nspire CX, HP Prime
  • Consoles, mobile devices and vintage computers owned: NES
FRC 4711 represent

Online Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 2661
  • Post Rating Ratio: +17/-1
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • View Profile
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: Unicorn's Ruby Questions and Programs
« Reply #12 on: July 19, 2015, 05:38:03 am »
Actually, that would be nice if someone writes a calc GUI for Nspire Linux and would support a lot of stuff the official GUI wouldn't.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)

In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii:

YUKI-CHAAAANNNN

Offline Unicorn

  • PICKACHUP IS LYFE
  • Super User
  • CW Contest II - 2nd place
  • *
  • Join Date: Jan 2015
  • Location: PICKACHUP land
  • Posts: 2715
  • Post Rating Ratio: +5/-2
  • make :PICKACHUP: a thing!
    • Unicorn808
    • 114/11432
    • View Profile
    • UnicornCalcs
  • Gender: Male
Re: Unicorn's Ruby Questions and Programs
« Reply #13 on: July 20, 2015, 04:56:29 pm »
Question! Is sprinting possible with ruby? I know you would have to get a gem, but is it possible? And if so. I saw some things about CSS sprite gems, would the CSS be the same as CSS with HTML?
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something
  • Consoles, mobile devices and vintage computers owned: PICKACHUP



Offline Unicorn

  • PICKACHUP IS LYFE
  • Super User
  • CW Contest II - 2nd place
  • *
  • Join Date: Jan 2015
  • Location: PICKACHUP land
  • Posts: 2715
  • Post Rating Ratio: +5/-2
  • make :PICKACHUP: a thing!
    • Unicorn808
    • 114/11432
    • View Profile
    • UnicornCalcs
  • Gender: Male
Re: Unicorn's Ruby Questions and Programs
« Reply #14 on: December 06, 2015, 07:29:14 pm »
I haven't posted here in a while, but anyways, I've been messing around with the Green_Shoes gem for GUI, and I ran into a problem.

This program I have quizzes the user. I have everything set up, but when the user gets the answer right, I can't get the screen to clear and allow new elements to be displayed. Is there like a ClrHome command?


I can post the code if need be, but I really am just asking for a command of some sort.
Thanks in advance.


Oh yeah, and I made the guessing game a little nicer looking.

Code: [Select]
require 'green_shoes'
guess = 0
ans = rand(1...50)
Shoes.app(title: "RubyGuess") do
  while 1
guess = ask("Guess a Numer from 1 - 50")
guess = guess.to_i
  if guess == ans
    alert "Great Job! You guessed the number!"
    if confirm("Quit?")
      exit
    end
  end
if guess != ans
  if guess > ans
    quit = confirm(" You did not guess the number. Try a lower number.")
  end
  if guess < ans
    quit = confirm(" You did not guess the number. Try a higher number")
  end
  if quit == false
    exit
  end
  end
  end
  end
run the .rb if you have ruby and the gem green_shoes installed. Otherwise, run the .exe. On windows it takes about 30-45 seconds to open, it has to do with Ocra's packaging.
« Last Edit: December 06, 2015, 07:43:33 pm by Unicorn »
  • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something
  • Consoles, mobile devices and vintage computers owned: PICKACHUP



 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games