Created
March 12, 2011 01:45
-
-
Save ashbb/866935 to your computer and use it in GitHub Desktop.
A solution for "Problem in script help (shoes)" posted by Lark Work in ruby-talk ML.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shoes.app :title => "PPID", :height => 400, :width => 700 do | |
background black, :height => 60 | |
background gradient(rgb(1.0, 1.0, 1.0, 0.7), rgb(1.0, 1.0, 1.0, 0.0)) | |
title "PPID", :align => "center", :stroke => white | |
caption "Personal: Person Info Database", :top => 80, :left => 20 | |
stack :top => 85, :left => 380 do | |
flow do | |
name = edit_line :width => 150 | |
button "Search" do | |
ds = SomeDataProcessing.openOn("PPIDdata.txt") | |
@eb.text = ds.showData(name.text) | |
end | |
button "List" do | |
dl = SomeDataProcessing.openOn("PPIDdata.txt") | |
@eb.text = dl.showlistData(name.text) | |
end | |
end | |
end | |
@eb = edit_box :width => 250, :height => 200, :top => 140, :left => 380 | |
#< between here there is a other part of the script but that is working fine> | |
class SomeDataProcessing | |
Person = Struct.new :name, :last_name, :phone_number, :birthday, :city, :adress | |
def self.openOn(p_file) | |
new(p_file) | |
end | |
def initialize(p_file) | |
@file = p_file | |
@persons = {} | |
loadData | |
end | |
def listData | |
@persons.keys.sort.each {|p| showlistData(p)} | |
end | |
def loadData | |
File.foreach(@file) do |line| | |
name, last_name, phone_number, birthday, city, adress = line.chomp.split(",") | |
@persons[name] = Person.new(name, last_name, phone_number, birthday, city, adress) | |
end | |
end | |
def showData(p_name) | |
person = @persons[p_name] | |
if person.nil? | |
then | |
@show_text2 = "#{p_name} not in database." | |
end | |
#stack do | |
@show_text2 = "Name: #{person.name} #{person.last_name}\n" \ | |
"Phonenumber: #{person.phone_number}\n" \ | |
"Birthday: #{person.birthday}\n" \ | |
"City: #{person.city}\n" \ | |
"Adress: #{person.adress}" | |
#end | |
#edit_box @show_text2, :width => 250, :height => 200, :top => 140, :left => 380 | |
end | |
def showlistData(p_name) | |
person = @persons[p_name] | |
if person.nil? | |
then | |
@show_text3 = "#{p_name} not in database." | |
end | |
@show_text3 = "#{person.name} #{person.last_name}" | |
debug @show_text3 | |
@show_text3 | |
#edit_box @show_text3, :width => 250, :height => 200, :top => 140, :left => 380 | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ashbb,shoes,010-223-3356,2011.3.11,Tokyo,Japan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment