source: de.wigbels.ruby/mob2archiv/doc/files/m2a_rb.src/M000002.html@ 85544a9

Last change on this file since 85544a9 was bc5d5b2, checked in by njw <njw@…>, 16 years ago

Initial Import

  • Property mode set to 100755
File size: 4.0 KB
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2<!DOCTYPE html
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6<html>
7<head>
8 <title>doCrudeObexAppComm (m2a.rb)</title>
9 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10 <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11</head>
12<body class="standalone-code">
13 <pre><span class="ruby-comment cmt"># File m2a.rb, line 24</span>
14<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">doCrudeObexAppComm</span>
15 <span class="ruby-keyword kw">begin</span>
16 <span class="ruby-identifier">cam</span> = <span class="ruby-identifier">getObexIOObject</span>
17 <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;ls&quot;</span>
18 <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">close_write</span>
19 <span class="ruby-identifier">lines</span> = <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">readlines</span>
20 <span class="ruby-identifier">cam</span> = <span class="ruby-identifier">getObexIOObject</span>
21 <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
22 <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/Bild\(\d+\).jpg/</span>
23 <span class="ruby-comment cmt">#black-magic-ruby $&amp; holds the match</span>
24 <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">$&amp;</span>.<span class="ruby-identifier">nil?</span>
25 <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;get&quot;</span>
26 <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">$&amp;</span>
27 <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">$destination</span><span class="ruby-operator">+</span><span class="ruby-value str">'/'</span><span class="ruby-operator">+</span><span class="ruby-identifier">$&amp;</span>
28 <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;copy picture &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">$&amp;</span><span class="ruby-operator">+</span><span class="ruby-value str">&quot; to to &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">$destination</span>
29 <span class="ruby-comment cmt">#delete picturea after copying? uncomment...</span>
30 <span class="ruby-comment cmt">#doesn't work on my phone:(</span>
31 <span class="ruby-comment cmt">#cam.puts &quot;delete&quot;</span>
32 <span class="ruby-comment cmt">#cam.puts $&amp;</span>
33 <span class="ruby-keyword kw">end</span>
34 <span class="ruby-keyword kw">end</span>
35 <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
36 <span class="ruby-identifier">puts</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">to_s</span>)
37 <span class="ruby-keyword kw">ensure</span>
38 <span class="ruby-comment cmt"># TODO: ensure connection is closed</span>
39 <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;disconnect&quot;</span>
40 <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">close</span>
41 <span class="ruby-keyword kw">end</span>
42<span class="ruby-keyword kw">end</span></pre>
43</body>
44</html>
Note: See TracBrowser for help on using the repository browser.