pull down to refresh

#curl this site and set to variable price = curl https://www.usdsat.com/ #We need to extract data in a predictable way. I'm guess, but look at the output yourself, that the line "1 US dollar is currently worth" is going to be its own independant line. From here we can extract the number. price = price.split("\n") #line 16 will probably contain the line we want, but verify. If this method is not predictable, don't use it. I'm using ruby as my example language. ruby sets the first object to 0 so to get the 16th object we will extract object 15 price = price[15] #price should now be "<center><h3>1 US dollar is currently worth <span id="current">4,790</span> sats</h3></center>" #Again we need to split this output in a predictable way price = price.split(">") price = price[3] #Right now our output should be "4,790</span" So we still need to get rid of what we don't want price = price.split("<") price = price[0] #Now price should equal "4,790". Reference this variable in your site. I assume an ERB syntax here (embedded ruby code used in ruby on rails) <footer> <p>$1 = <%= price %> Satoshi</p> </footer>
What language is this? Just starting to learn to code and might try playing with this in Replit.
reply
Ruby mostly. Here's the thing with throwing up example code on the fly tho, I didn't run any of it to test. I'm already noticing things I missed. Like the fact that curl is a terminal command not native to ruby so you have to make a system call
price = system("curl https://www.usdsat.com/")
Bottom part is html5 but it uses ERB (embedded ruby) into the erb file (which is used instead of an html file) specifically used in the web development framework "ruby on rails".
Also, if you want to make a desktop app, I found the "glimmer" gem (modules in ruby are called gems) to be pretty good for that. glimmer references several ui frameworks and I like to use libui through glimmer.
ruby is an interpretive language, but it interprets to C (the programming language) so if you use sorbet and llvm you can compile your code rather than interpret it.
You should click on my nym here on stacker news. I got my repl linked where you can see some stuff I worked on (in the portfolio folder, the other folders were useful projects I forked)
reply