Radiator
Is a ruby gem written by @inertia its an API to talk to steemit blockchain via ruby.
We are going to further Easify this radiator Gem in here.. so that we can do something like this
Which should return us bilal-haider's 10 followers
like so
Create a Module which makes it easy to use Radiator gem :) <3
Creating a directory called Analyzer
cd to this directory and install radiator and paint gems
gem install radiator
and also install paint gem, for give our text colors in terminal
gem install paint
You will see that, after creating an EasySteem module, how easily we can talk to steem blockchain
puts EasySteem.reblog_stream
will start a steam for us, where it will show us who is sharing whom posts at the moment :)
like so
Lets start by analyzing what operations steem blockchain provides us :p
- we can post
- we can vote
- we can transfer
- we can claim rewards
- we can flag
- we can comment
- we can watch streams :)
We don't have a lot of methods in this module, but we can extend it in upcoming articles. This way we can create an Easy Api to interact with steem blockchain
Our module so far has only 7 methods in it :p thanks to my laziness
You don't need to understand this code, if you don't want to.. you should be able to use it that's what matters :)
require 'radiator'
require 'json'
require 'paint'
module EasySteem
def EasySteem.supply
api = Radiator::Api.new
api.get_dynamic_global_properties do |properties|
properties.virtual_supply
end
end
def EasySteem.followers(*options)
api = Radiator::FollowApi.new
if options[2] == nil
_start = 0
elsif
_start = options[2]
end
api.get_followers(options[0], _start, 'blog', options[1]) do |followers|
followers.map(&:follower)
end
end
def EasySteem.voting_stream
stream = Radiator::Stream.new
stream.operations(:vote) do |op|
print "#{op.voter} voted for #{op.author}"
puts " (weight: #{op.weight / 100.0}%)"
end
end
def EasySteem.comment_stream
stream = Radiator::Stream.new
stream.operations(:comment) do |op|
if op.parent_author != ""
print "#{op.author} commented on #{op.parent_author}\'s Post. "
puts "Permlink: #{op.parent_permlink}"
elsif
print "#{op.author} commented on a Post. \n"
puts "Permlink: #{op.permlink}"
end
end
end
def EasySteem.follow_stream
stream = Radiator::Stream.new
stream.operations(:custom_json) do |op|
if op.id == "follow"
_myhash = JSON.parse(op.json)
if _myhash[0] == "follow"
_info = _myhash[1]
puts "#{Paint[_info['follower'], :red]} has followed #{Paint[_info['following'], :green]}"
end
end
end
end
def EasySteem.reblog_stream
stream = Radiator::Stream.new
stream.operations(:custom_json) do |op|
if op.id == "follow"
_myhash = JSON.parse(op.json)
# p _myhash
if _myhash[0] == "reblog"
_info = _myhash[1]
puts "#{Paint[_info['account'], :green]} has shared #{Paint[_info['author'], :cyan]}\'s Post"
end
end
end
end
def EasySteem.stream
stream = Radiator::Stream.new
stream.operations do |op|
puts op
end
end
end
Once you have gems installed an you also have EasySteem module. you are ready to use it like so
require_relative 'easysteem'
puts EasySteem.supply
Which returns virtual Steem supply ..
get reblogs stream
require_relative 'easysteem'
puts EasySteem.reblog_stream
which outputs
Get followers of a person
require_relative 'easysteem'
## returns bilal-haider's 10 followers
puts EasySteem.followers "bilal-haider", 10
## returns bilal-haider's 10 followers starting from "a-0-a"
puts EasySteem.followers "bilal-haider", 10, "a-0-a"
Get virtual Steem Supply
require_relative 'easysteem'
puts EasySteem.supply
Get following stream.. see who is following whom at real time
require_relative 'easysteem'
puts EasySteem.follow_stream
require_relative 'easysteem'
puts EasySteem.follow_stream
puts EasySteem.supply
puts EasySteem.followers "bilal-haider", 100
puts EasySteem.stream
puts EasySteem.voting_stream
puts EasySteem.comment_stream
puts EasySteem.follow_stream
puts EasySteem.reblog_stream
These are few other Methods which you can call using EasySteem
I hope you liked it. ;)
Once again brother good stuff. Like I said before, you're helping people so stay at it. Just wanted to stop by and offer words of encouragement and to give you a up vote. stay at it and keep doing such a great job. I hope you had a great day. I'll talk at you later.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for stopping by :) appreciate that.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Lovely lesson
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
glad you loved it :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Yea.....keep booming
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good post 👍👍👍
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks :) I am glad you liked it :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You got a 1.13% upvote from @getup
Want to promote your posts too? Send at least 0.005 STEEM DOLLAR or STEEM (max 0.025) to @getup with the post link as the memo and receive a upvote! More profits? 100% Payout! Delegate some SteemPower to @getup
1 SP, 5 SP, 10 SP, custom amount
► ► For Resteem to over 1400 follower + Upvote from @getup send 0.026 SBD with the post link as the memo.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Ok @bilal-haider i got captivated by this code and what it can do. I understand just a little about the "if then else statements" I was once familiar years ago. Your sharing got me interested. I might buy me a book and explore further on this particular language. Thanks a bunch and enjoy developing...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit